Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Problem executing a BAT file (or EXE file) using Perl as CGI script under Apache.

Reply
Thread Tools

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

 
 
Tom Salzmann
Guest
Posts: n/a
 
      07-14-2003
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


 
Reply With Quote
 
 
 
 
Cat
Guest
Posts: n/a
 
      07-15-2003
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
 
Reply With Quote
 
 
 
 
Tom Salzmann
Guest
Posts: n/a
 
      07-15-2003
The return code I get is 65280... exit_code of 255.

??

Thoroughly confused...

Tom

"Tom Salzmann" <(E-Mail Removed)> wrote in message
news:zjUQa.458$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Cat
Guest
Posts: n/a
 
      07-16-2003
Tom Salzmann wrote:
>
> The return code I get is 65280... exit_code of 255.
>
> ??
>
> Thoroughly confused...
>
> Tom
>
> "Tom Salzmann" <(E-Mail Removed)> wrote in message
> news:zjUQa.458$(E-Mail Removed)...
> > 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert exe file of cgi script into .cgi extension. Muzammil C++ 1 08-28-2008 07:50 PM
Executing a .bat file from my code Meidan Java 6 06-26-2008 07:14 AM
Issue in executing more than one perl script from Single perl script nilesh.sonawane@gmail.com Perl Misc 3 11-01-2007 06:19 PM
what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server? kath Perl Misc 4 04-09-2007 09:21 PM
cgi invoked .bat script can't access network drives! Jonas Perl 4 06-22-2004 04:45 PM



Advertisments