SYSTEM command problem

Discussion in 'Perl Misc' started by dcs_thebob@yahoo.com, Apr 20, 2006.

  1. Guest

    I have a Win2003 server running as a webserver. This box crashed
    recently and I had to load all my .pl scripts from a backup. Now, I
    have the site up and running, but one of my scripts isn't functioning
    the way I need.

    Basically, the script does its thing by creating a temp file, then uses
    a simple dos based smtp mailer to send the file out via email (blat).
    I can run the script from the website and it creates the file fine.
    But the last line of code runs a SYSTEM command that calls Blat.exe and
    emails the file, doesn't execute.

    I can run Blat from the command line, with the same options and it
    works fine. I even hard coded my email address and the same switches
    in the System command in the script and it didn't work. I have given
    the EVERYONE group full rights to the blat.exe file and folder. I'm
    down to this one issue and this server is up and going. Any ideas will
    be appreciated.

    tb
     
    , Apr 20, 2006
    #1
    1. Advertising

  2. "" <> writes:

    > Basically, the script does its thing by creating a temp file, then uses
    > a simple dos based smtp mailer to send the file out via email (blat).
    > I can run the script from the website and it creates the file fine.
    > But the last line of code runs a SYSTEM command that calls Blat.exe and
    > emails the file, doesn't execute.


    Perl will tell you what's wrong - if you ask it to.

    system('foo -b -a -r') != -1
    or die "Could not run foo. Reason: $!";

    For that matter, there may already be messages from blat.exe in your error
    log, if perl is able to launch it, but it's failing for some reason. The
    child process launched by system() inherits perl's stdin and stdout.

    Another place to look for clues would be blat.exe's error log, if it has
    one.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Apr 20, 2006
    #2
    1. Advertising

  3. Guest

    Thanks for the info. I'm a complete Perl noob, so this will come in
    handy. In my current setup the script is ran from a website, so where
    would the Reason code and all be displayed/output to? It doesn't show
    up on the website (obviously), so does perl have a "normal" log file
    that would receive this kind of message?

    thanks again, sorry for the basic questions.

    tb
     
    , Apr 20, 2006
    #3
  4. "" <> writes:

    > Thanks for the info.


    You can thank me by doing everyone here a favor: Quote the messages you
    are replying to, like the rest of us do. Thanks.

    > In my current setup the script is ran from a website, so where
    > would the Reason code and all be displayed/output to?


    Your web server's error log.

    Or, you can use the CGI::Carp module to have the error messages sent to
    the browser instead:

    use CGI::Carp qw(fatalsToBrowser);

    > up on the website (obviously), so does perl have a "normal" log file
    > that would receive this kind of message?


    The child process started with system() inherits stdin, stdout, and stderr
    from Perl. Web servers generally route the stderr from a CGI to the web
    server's error log.

    Although, I don't know what web server you're using, so I can't swear that
    it's doing that.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Apr 20, 2006
    #4
  5. Sherm Pendley wrote:
    > "" <> writes:
    >
    >>Basically, the script does its thing by creating a temp file, then uses
    >>a simple dos based smtp mailer to send the file out via email (blat).
    >>I can run the script from the website and it creates the file fine.
    >>But the last line of code runs a SYSTEM command that calls Blat.exe and
    >>emails the file, doesn't execute.

    >
    > Perl will tell you what's wrong - if you ask it to.
    >
    > system('foo -b -a -r') != -1
    > or die "Could not run foo. Reason: $!";


    perldoc -f system
    [snip]
    @args = ("command", "arg1", "arg2");
    system(@args) == 0
    or die "system @args failed: $?"


    You will probably get a better error message if you use $? instead of $!.


    John
    --
    use Perl;
    program
    fulfillment
     
    John W. Krahn, Apr 20, 2006
    #5
  6. "John W. Krahn" <> writes:

    > Sherm Pendley wrote:
    >> "" <> writes:
    >>
    >>>Basically, the script does its thing by creating a temp file, then uses
    >>>a simple dos based smtp mailer to send the file out via email (blat).
    >>>I can run the script from the website and it creates the file fine.
    >>>But the last line of code runs a SYSTEM command that calls Blat.exe and
    >>>emails the file, doesn't execute.

    >>
    >> Perl will tell you what's wrong - if you ask it to.
    >>
    >> system('foo -b -a -r') != -1
    >> or die "Could not run foo. Reason: $!";

    >
    > perldoc -f system
    > [snip]
    > @args = ("command", "arg1", "arg2");
    > system(@args) == 0
    > or die "system @args failed: $?"
    >
    >
    > You will probably get a better error message if you use $? instead of $!.


    Mea culpa - I *did* perldoc -f system, but didn't read far enough down. A
    couple of paragraphs above the above example, there's this:

    Return value of -1 indicates a failure to start the program (inspect
    $! for the reason).

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Apr 20, 2006
    #6
  7. <> wrote:

    > I'm a complete Perl noob,



    That is irrelevant, since your question is not about your
    choice of programming language.


    > In my current setup the script is ran from a website, so where
    > would the Reason code and all be displayed/output to? It doesn't show
    > up on the website (obviously), so does perl have a "normal" log file
    > that would receive this kind of message?



    Where your web server puts messages has no relationship to what
    programming language you have chosen to write your CGI program.

    If you wrote it in Python, the program's output would go to the
    same place(s) as if you wrote it in Perl or Visual Basic.

    You don't have a programming language question.

    You have a web server configuration question.

    Ask web server configuration questions in a newsgroup that has
    some connnection with WWW stuff, such as:

    comp.infosystems.www.servers.mac
    comp.infosystems.www.servers.misc
    comp.infosystems.www.servers.ms-windows
    comp.infosystems.www.servers.unix


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Apr 21, 2006
    #7
  8. Ben Morrow Guest

    Quoth Sherm Pendley <>:
    > "John W. Krahn" <> writes:
    > > Sherm Pendley wrote:
    > >>
    > >> Perl will tell you what's wrong - if you ask it to.
    > >>
    > >> system('foo -b -a -r') != -1
    > >> or die "Could not run foo. Reason: $!";

    > >
    > > perldoc -f system
    > > [snip]
    > > @args = ("command", "arg1", "arg2");
    > > system(@args) == 0
    > > or die "system @args failed: $?"
    > >
    > >
    > > You will probably get a better error message if you use $? instead of $!.

    >
    > Mea culpa - I *did* perldoc -f system, but didn't read far enough down. A
    > couple of paragraphs above the above example, there's this:
    >
    > Return value of -1 indicates a failure to start the program (inspect
    > $! for the reason).


    In general you need to inspect all of $?, $!, and, on Win32, $^E to find
    out what went wrong. If the fork or exec (or spawn, as appropriate)
    failed, the error is in $! and/or $^E. If the program started correctly,
    but exitted with an error status, that will be in $?.

    Go read perlvar again :)

    Ben

    --
    'Deserve [death]? I daresay he did. Many live that deserve death. And some die
    that deserve life. Can you give it to them? Then do not be too eager to deal
    out death in judgement. For even the very wise cannot see all ends.'
     
    Ben Morrow, Apr 24, 2006
    #8
    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. Charlie Zhang
    Replies:
    5
    Views:
    6,565
    Qu├ębec
    Jun 19, 2004
  2. Irmen de Jong
    Replies:
    2
    Views:
    449
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=
    Aug 12, 2003
  3. jon c
    Replies:
    1
    Views:
    356
    Thomas Heller
    Feb 10, 2004
  4. Replies:
    0
    Views:
    340
  5. boriq
    Replies:
    4
    Views:
    623
    Tim Golden
    Jun 12, 2008
Loading...

Share This Page