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

T

Tom Salzmann

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
 
C

Cat

Tom said:
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
 
T

Tom Salzmann

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

??

Thoroughly confused...

Tom
 
C

Cat

Tom said:
The return code I get is 65280... exit_code of 255.

??

Thoroughly confused...

Tom

Sorry i can't help you any further as I'm running Linux and W2K. But I'll
keep thinking... good luck.
 

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,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top