strange problem..program not working through web form.

S

seemanta dutta

Hi,
I have a simple form which when clicked mails a user via the cgi script.

But the problem is that when I run the script from the commandline it works well.
but the moment I try to do it via the form it simply fails.
here's the cgi script:(mail.pl)

#!/usr/bin/perl -w

system("cat mail.txt | /bin/mail -s hello foo\@foobar.com");


printf "Content-type: text/html\n\n";
printf "wait...\n" ;

and here is the form:(mail.html)

<html>

<p> Just click and Submit!! </p>
<form method=GET action="/cgi-bin/mail.pl">
<input type="submit" name="sub_button" value="Click!" >
</form>

</html>

P.S. I have mail installed on my system and it works fine from the shell.
it does not only via the webserver.

please help,

thanks in advance,
regards,
Seemanta
 
J

Jürgen Exner

seemanta said:
I have a simple form which when clicked mails a user via the cgi
script.

But the problem is that when I run the script from the commandline it
works well. but the moment I try to do it via the form it simply
fails.

Then chances are very high that your problem is not a Perl problem.
Please see "perldoc -q 500" for further details.

Also, what does the error log say?
here's the cgi script:(mail.pl)

#!/usr/bin/perl -w

system("cat mail.txt | /bin/mail -s hello foo\@foobar.com");

A typical example of useless use of 'cat'.
And why aren't you checking for an error condition?

Wild guess: Does the user, who is used to run CGI programs on your web
server, have permission to execute cat and /bin/mail? Of course this has
nothing to do with Perl.
printf "Content-type: text/html\n\n";
printf "wait...\n" ;

Why are you using a formatted print?
[...]
P.S. I have mail installed on my system and it works fine from the
shell. it does not only via the webserver.

What about "it works fine when using the UID of the web server"?

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top