Problem executing a BAT file (or EXE file) using Perl as CGI script under Apache.

Discussion in 'Perl Misc' started by Tom Salzmann, Jul 14, 2003.

  1. Tom Salzmann

    Tom Salzmann Guest

    I have developed some perl code to run as a script under Windows 2000
    running apache. This works GREAT on Win2k but on WinNT, perl is simply
    unable to launch the program. The program works fine from the command line.

    Here's the code:

    $fred=time . ".out" ;
    open(OUTPUT, "|imon.bat " . $fred . " " . $ENV{'REMOTE_ADDR'} . " " .
    $IMCommand . " " . $IMFile );
    close OUTPUT;
    open(FILE, $fred );
    @htmlLines = <FILE>;
    close FILE ;
    unlink($fred);
    unlink($IMFile);

    As a test to make sure I wasn't nuts, I put the following in the bat file:

    ECHO >> echo.out

    And sure enough, I get "ECHO IS ON" in the file every time I run from
    command line. But when I run from Apache, I get NOTHING. It's as if Apache
    is unable to launch the thing.

    Again, this works FINE under Win2k but fails on WinNT - Any ideas? I tried
    system() but I get the same thing.


    Thanks,

    Tom
     
    Tom Salzmann, Jul 14, 2003
    #1
    1. Advertising

  2. Tom Salzmann

    Cat Guest

    Re: Problem executing a BAT file (or EXE file) using Perl as CGI scriptunder Apache.

    Tom Salzmann wrote:
    >
    > I have developed some perl code to run as a script under Windows 2000
    > running apache. This works GREAT on Win2k but on WinNT, perl is simply
    > unable to launch the program. The program works fine from the command line.
    >
    > Here's the code:
    >
    > $fred=time . ".out" ;
    > open(OUTPUT, "|imon.bat " . $fred . " " . $ENV{'REMOTE_ADDR'} . " " .
    > $IMCommand . " " . $IMFile );
    > close OUTPUT;
    > open(FILE, $fred );
    > @htmlLines = <FILE>;
    > close FILE ;
    > unlink($fred);
    > unlink($IMFile);
    >
    > As a test to make sure I wasn't nuts, I put the following in the bat file:
    >
    > ECHO >> echo.out
    >
    > And sure enough, I get "ECHO IS ON" in the file every time I run from
    > command line. But when I run from Apache, I get NOTHING. It's as if Apache
    > is unable to launch the thing.
    >
    > Again, this works FINE under Win2k but fails on WinNT - Any ideas? I tried
    > system() but I get the same thing.
    >
    > Thanks,
    >
    > Tom


    Check the Apache log files for clues
    Include the full path to imon.bat and see if that works
    Maybe try hard coding the parameters to imon.bat or simplifying it
    eg open(OUTPUT, "|imon.bat 1234.out 127.0.0.1 echo test.txt");

    inet.bat can be something like

    ECHO %1 %2 %3 %4 >> echo.out
     
    Cat, Jul 15, 2003
    #2
    1. Advertising

  3. Tom Salzmann

    Tom Salzmann Guest

    Re: Problem executing a BAT file (or EXE file) using Perl as CGI script under Apache.

    The return code I get is 65280... exit_code of 255.

    ??

    Thoroughly confused...

    Tom

    "Tom Salzmann" <> wrote in message
    news:zjUQa.458$...
    > Cat, Thanks for the reply.
    >
    > I have tried your advice to no avail. The perl file works FINE from the
    > commandline and it does RUN from apache (I echo things to the resulting
    > html) but the calls to NT to run the BAT file fail... I tried it two ways
    > this time - the open() approach and using system().
    >
    > Again, from the commandline, the PERL program runs the BAT file fine every
    > time. From Apache, the perl file runs but the BAT file is apparently
    > ignored.... I'll try to get return codes from system() next.
    >
    > Thanks!
    > Tom
    >
    >
     
    Tom Salzmann, Jul 15, 2003
    #3
  4. Tom Salzmann

    Cat Guest

    Re: Problem executing a BAT file (or EXE file) using Perl as CGI scriptunder Apache.

    Tom Salzmann wrote:
    >
    > The return code I get is 65280... exit_code of 255.
    >
    > ??
    >
    > Thoroughly confused...
    >
    > Tom
    >
    > "Tom Salzmann" <> wrote in message
    > news:zjUQa.458$...
    > > Cat, Thanks for the reply.
    > >
    > > I have tried your advice to no avail. The perl file works FINE from the
    > > commandline and it does RUN from apache (I echo things to the resulting
    > > html) but the calls to NT to run the BAT file fail... I tried it two ways
    > > this time - the open() approach and using system().
    > >
    > > Again, from the commandline, the PERL program runs the BAT file fine every
    > > time. From Apache, the perl file runs but the BAT file is apparently
    > > ignored.... I'll try to get return codes from system() next.
    > >


    Sorry i can't help you any further as I'm running Linux and W2K. But I'll
    keep thinking... good luck.
     
    Cat, Jul 16, 2003
    #4
    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. Jonas
    Replies:
    4
    Views:
    964
  2. Muzammil
    Replies:
    1
    Views:
    1,185
    red floyd
    Aug 28, 2008
  3. mastar
    Replies:
    5
    Views:
    162
  4. kath
    Replies:
    4
    Views:
    703
    J. Gleixner
    Apr 9, 2007
  5. Michael Vilain
    Replies:
    7
    Views:
    473
    Michael Vilain
    Feb 18, 2013
Loading...

Share This Page