Find the answer to your Linux question:
Results 1 to 4 of 4
Hello all, I trying from some C code to send and emal. I use a call to system( "..." ); to do this When I run the program as a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2006
    Location
    UK
    Posts
    5

    Can't mail from CGI script


    Hello all,

    I trying from some C code to send and emal.
    I use a call to system( "..." ); to do this

    When I run the program as a user logged onto the server it works correctly
    When I run the program as a CGI script from a web browser, it fails as below:

    "Null message body; hope that's ok"

    command line string used:
    "mail -n -s "My subject" someone@somewhere.com < myfile.txt"

    The file is myfile.txt is created by the same process, and can be read using "head" issued using system( "..." ); from the same code, so file access is not a problem.

    Any help appreciated.

    Regards
    Dave

  2. #2
    Linux User muha's Avatar
    Join Date
    Jan 2006
    Posts
    290
    It looks like you need to escape the double quotes (") as well as the ad (@) because they are breaking up your command. I don't know how that works for CGI, my guess would be:
    Code:
    "mail -n -s \"My subject\" someone\@somewhere.com < myfile.txt"
    http://www.expertwebinstalls.com/ins...i_scripts.html
    Now what? You have Linux installed and running. The GUI is working fine, but you are getting tired of changing your desktop themes. You keep seeing this "terminal" thing. Don't worry, they'll show you what to do @
    <~ http://www.linuxcommand.org/ ~>

  3. #3
    Just Joined!
    Join Date
    Apr 2006
    Location
    UK
    Posts
    5
    muha,

    I dont see how the escape sequences help (I already have them for the quotes in the code).

    The code already works, but only when invoked as a known user at a command prompt. It just seems to fail when the user name is nobody, as occurs when the code is run from a web browers as a CGI.

    Thanks for your help.

    Regards
    Dave

  4. #4
    Linux User muha's Avatar
    Join Date
    Jan 2006
    Posts
    290
    Quote Originally Posted by DaveTheRave
    command line string used:
    "mail -n -s "My subject" someone@somewhere.com < myfile.txt"
    ....
    I dont see how the escape sequences help (I already have them for the quotes in the code).
    I don't see quotes. Please post the literal command you're using then ..
    Now what? You have Linux installed and running. The GUI is working fine, but you are getting tired of changing your desktop themes. You keep seeing this "terminal" thing. Don't worry, they'll show you what to do @
    <~ http://www.linuxcommand.org/ ~>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •