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

Humble greetings Monks, I am utilizing the win32::process to start a detached perl cgi script. This works fine in DOS command line environment and also works in the web environment to some extent - EXCEPT passing CGI parameters.
my $perlexe = $^X; my $ProcessObj1 =0; Win32::Process::Create($ProcessObj1, "$perlexe", "perl d:\cgi-bin\drop_tbl.pl TEMP_TABLE=EX_TMP +1 DSN=SID1", 0, DETACHED_PROCESS, ".");
The drop_tbl.pl script is started but it never receives the cgi parameters. What's wrong here? I have confirmed that this works perfectly when run on the DOS command line. (Environment: WIN2K server, IIS, ActivePerl 5.6) Grateful for any help. Cheers, Skinne
  • Comment on win32::process - "child" perl script never receives cgi parameters
  • Download Code

Replies are listed 'Best First'.
Re: win32::process - "child" perl script never receives cgi parameters
by BrowserUk (Patriarch) on Dec 04, 2002 at 09:59 UTC

    When you create a DETATCHED_PROCESS, the process does not have the standard io handles STDIN, STDOUT and STDERR. As cgi parameters are supplied to the script via STDIN (and output to the browser via STDOUT) there is nowhere for a detached process to read from or write to.


    Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
    Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
    Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
    Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

      Hi BrowserUk,
      Thanks for your reply,- So how come this works fine when run from DOS command or e.g. via the Task Scheduler?

      I have a different script for scheduled report execution which calls it self a number of times in detached processes and in turn executes other Perl scripts depending on which parameters is passed to it.
      This works great!

      So thís problem only appears when run via the web interface.
      I can work around this by executing the detached script via a system command from the CGI script, but this isn't nearly as elegant.

      Cheers, Kristian
Re: win32::process - "child" perl script never receives cgi parameters
by martymart (Deacon) on Dec 04, 2002 at 11:55 UTC
    Do you have your App mappings set correctly for IIS? To run perl as a cgi application, type the full path to Perl.exe followed by %s %s. When a script is executed, the first %s will be replaced by the full path to the script, and the second %s will be replaced by the script parameters. To do this go to web site properties/Home Directory tab/Configuration... button/ and edit your paths there. Something like: C:\Perl\bin\perl.exe %s %s