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

I'm trying to use the exec function that loads another script with a .cgi extension (manager.cgi), which is in the same directory. This is what I have so far:

exec('manager') || dienice("Could not run manager");

In the above code, it results with the dienice subroutein returning the error message, as appropriate. I'm new to the exec function, and I cannot get it to work. What am I doing wrong?
  • Comment on running exec script.cgi from a cgi script

Replies are listed 'Best First'.
Re: running exec script.cgi from a cgi script
by btrott (Parson) on May 18, 2000 at 03:05 UTC
    You need to put the .cgi extension--it's not assumed. exec runs another program on your *filesystem*. So you may also have to use the full path to manager.cgi.
    exec '/full/path/to/manager.cgi' or dienice("Could not run manager");
Re: running exec script.cgi from a cgi script
by merlyn (Sage) on May 18, 2000 at 20:05 UTC
    In general, you can't just "exec" from one CGI program to another. The second program is probably expecting all the CGI environment to be set up properly, and the first program is expected to return a CGI response to the web server. So, you probably need to restate your problem in terms of what you really want to accomplish, because, "you can't get there from here".

    -- Randal L. Schwartz, Perl hacker

Re: running exec script.cgi from a cgi script
by mcwee (Pilgrim) on May 18, 2000 at 04:24 UTC
    This doesn't really address the question you asked, but: Is it possible that do might serve your purposes better?

    The Autonomic Pilot

Re: running exec script.cgi from a cgi script
by zodiac (Beadle) on May 18, 2000 at 15:22 UTC
    Make sure to set the $ENV{"QUERY_STRING"} as you need it before calling the manager. This is were CGI skripts get the data from. (or at least the CGI module.)
Re: running exec script.cgi from a cgi script
by BigJoe (Curate) on May 18, 2000 at 04:13 UTC
    You should be able to just use relative path to the .cgi just make sure you have the complete name 'manager.cgi'. I found it is easier if you move your scripts that are all located in a dir together using a relative path.  exec 'manager.cgi' or dienice("Could not run manager");