Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Why does fork/exec not work on Win NT 4.0 Server?

by LupoX (Pilgrim)
on Jul 23, 2001 at 20:00 UTC ( [id://99063]=perlquestion: print w/replies, xml ) Need Help??

LupoX has asked for the wisdom of the Perl Monks concerning the following question:

Hi all!

I try to run "unzip" out of a cgi-script served by Apache under Win NT 4.0 Server.
The same code worked fine with another istallation on Win NT 4.0 (not Server Edition)
Now I always get the"Internal Server error" I try to run my cgi script. The perl interpreter does not say anything while running from dos box.
I checked file permissions and Apache is running as Administrator.
Help would be great!!!

Perl Version 5.005_03

my $file = "bla.zip";
my $command = "p:/tools/wni/unzip.exe $myFile";
unless (defined ($pid = fork)) {
print "No fork:$!\n";
}
unless ($pid) {
exec ($command) or print "exec $command not possible:$!";
exit;
}
waitpid ($pid, 0);



Have a good time...
Georg

wrkvg@SoftwareAG.com
  • Comment on Why does fork/exec not work on Win NT 4.0 Server?

Replies are listed 'Best First'.
Re: Why does fork/exec not work on Win NT 4.0 Server?
by abstracts (Hermit) on Jul 23, 2001 at 22:44 UTC
    Hello,

    A few notes about your code:

    • In the second line, $myFile is not defined. I think you wanted to use $file.
    • You are printing "No fork: $!\n" without first printing "Content-type: text/html\n\n"; This causes 500 Fatal Error.
    • You are forking a process that execs to unzip a file. The main process however sits idle waitpiding for the child to exit. You should've just used system to unzip the file and return to the user.
    • You can also use the Archive::Zip module instead of firing another process just to do the unzipping.
    Hope this helps,,,

    Aziz,,,

Re: Why does fork/exec not work on Win NT 4.0 Server?
by bikeNomad (Priest) on Jul 23, 2001 at 20:23 UTC
    Try using CGI::Carp and fatalsToBrowser to find out what your problem is.

    But first, do you have unzip in the same place on both systems?

      Hi Mr Nomad! I checkes environment and zip / unzip is in the PATH variable. This works.

      From command line there are no Problems. I also tried to exec the executable with full destination path.

      exec (c:/tools/unzip $file); which also does not work.

      Thanks for Your time... Georg
(tye)Re: Why does fork/exec not work on Win NT 4.0 Server?
by tye (Sage) on Jul 24, 2001 at 11:52 UTC

    Win32 Perl 5.005 supports fork emulation but just barely. I found it very easy to break.

    abstracts is correct. In particular, use system rather than doing the fork and exec yourself; it is more portable.

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://99063]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-24 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found