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

Hi

I'm trying to write a CGI that's a simple wrapper script around ASPSeek. I want to tinker with the environment variables, and maybe filter the output, though this might not be necessary. What I'm trying at the moment:

#!/usr/bin/perl print "Content-type: text/html\n\n"; print `/path/to/aspseek/s.cgi`;

This works fine from the command line run as the user Apache runs as (nobody), and s.cgi runs fine a standalone CGI, but nothing gets printed when I run it within the wrapper script; the backticks return an empty string. $? is 0. What I'm wondering is how "the outside" looks different to a CGI run in backticks by a perl CGI. Incidentally, exec doesn't work either.

cheers
ViceRaid

Replies are listed 'Best First'.
Re: Backticks and exec within a CGI
by Abigail-II (Bishop) on Feb 20, 2004 at 14:48 UTC
    Note that the environment is different when running as a CGI program, and running from the command line. This includes, but is not limited to, (E)UID, (E)GID, environment variables, and the root file system.

    $? suggests that /path/to/aspseek/s.cgi was run, and was run successfully. It just might have decided not to output anything.

    Abigail

Re: Backticks and exec within a CGI
by skx (Parson) on Feb 20, 2004 at 17:30 UTC

    Do you see anything in your servers error logs?

    It might be the case, for example, that the s.cgi script you are calling won't like getting called in this manner - expecting to be able to use PATH_INFO or some other variable which you've not massaged correctly.

    Steve
    ---
    steve.org.uk

      Ah, yes, that's it. It works when I massage SCRIPT_URL so it reflects the original CGI, it works. It turns out that the application uses this to find a template file, but doesn't complain or fall back to a default if this file's missing, it just prints nothing and returns a success.

      cheers
      ViceRaid