strange problem..program not working through web form.

Discussion in 'Perl' started by seemanta dutta, Feb 6, 2004.

  1. 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
     
    seemanta dutta, Feb 6, 2004
    #1
    1. Advertising

  2. seemanta dutta wrote:
    > 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
     
    Jürgen Exner, Feb 6, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jurjen de Groot
    Replies:
    2
    Views:
    3,790
    Jurjen de Groot
    Aug 28, 2006
  2. ~neil~
    Replies:
    7
    Views:
    575
    George Fulk
    Sep 28, 2004
  3. Ajinkya
    Replies:
    65
    Views:
    1,206
    Keith Thompson
    Oct 9, 2007
  4. Zhang Weiwu
    Replies:
    4
    Views:
    121
  5. G G
    Replies:
    6
    Views:
    215
Loading...

Share This Page