| evillen@gmail.com 2005-07-26, 5:00 pm |
| I have tried to create a small test case to demonstrate a problem I am
having with a System call generated by my CGI script. I have tried to
make two System calls as similar as possible - one works as expected
the other continually fails.
I have two system calls in the source code (see below), the first
system call returns a "0" indicating that the process exited
successfully while the second system call returns "65280" which
indicates a failure.
Both of the System programs "testapp" and "extracta" and any input
files reside in the CWD. The first system call using @prog1 has also
been successfully tested to write output locally which is similar to
the desired @prog2 execution.
The system call that fails here (@prog2) works successfully in a
non-CGI environment.
My configuration is: ActivePerl 5.8, OS is WinXP pro, Apache/2.0.54 Web
server installed on my local PC as
http://localhost/~myname/tests_d/external_d.cgi
The apache Error log (see below) is probably the biggest clue to the
problem saying:
"Can't spawn "extracta.exe": No error at..."
The "No error at" part is particularly confusing. Line 22 of the code
is "my $exit_status2 = system(@prog2);"
Program result
--------------
External command test
My CWD is C:/Documents and Settings/myname/My Documents/My
Website/tests_d
Exit status1: 0
Exit status2: 65280
error.log
---------
[Tue Jul 26 15:34:12 2005] [error] [client 127.0.0.1] [Tue Jul 26
15:34:12 2005] external_d.cgi: Can't spawn "extracta.exe": No error at
C:/Documents and Settings/myname/My Documents/My
Website/tests_d/external_d.cgi line 22., referer:
http://localhost/~myname/tests_d/
source code
-----------
#!c:/perl/bin/perl.exe -wT
use strict;
use diagnostics;
use CGI;
use CGI::Carp;
use Cwd;
my $q = new CGI;
print $q->header,
$q->start_html(-title => "External program"),
$q->h2("External command test");
$ENV{'PATH'} = ("C:\\WINDOWS\\system32");
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
my @prog1 = ("testapp.exe", "+R", "dummy.txt", "/S");
my @prog2 = ("extracta.exe", "temp.brd", "status_detail.cmd",
"extract_output.txt");
my $exit_status1 = system(@prog1);
my $exit_status2 = system(@prog2);
my $dir = getcwd();
print $q->p("My CWD is $dir"),
$q->p("Exit status1: $exit_status1"),
$q->p("Exit status2: $exit_status2"),
$q->end_html;
|