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

I've got a webpage where I want a specific output if a there is no data to display. I've set the output up as a cgi script which runs fine on it's own. When I try to call the script through system it returns a failure with the value of -1. I've now put the system call in a script on its own to make sure that it is where the probelm is. It is.
I tried the trouble shooting code in the perldocs but got a syntax error for some reason.
My entire code for calling the script is below:
#!/usr/bin/perl -w use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use strict; print header; print start_html; system("/cgi/empty.cgi")== 0 or die "system failed: $?"; print end_html;

Can anyone see what I have done wrong here?
Thanks in advance for your help.

Replies are listed 'Best First'.
Re: Problems getting system call to work
by friedo (Prior) on Nov 18, 2006 at 05:21 UTC
    You're passing an absolute pathname to your script, but I doubt the /cgi directory is at the root of your filesystem. You need to give the real path to the script, not the web server's document path.
      Thanks for that friedo
      It's all sorted. Just out of interest, is it possible to enter a relative path name? From memory I think I tried that and got the same result but if I'm reading between the lines of your reply correctly I didn't have to use an absolute path.
        Yes, you can pass a relative path. However, it's relative to your current directory, which is not necessarily the one in which the calling script resides. Some web servers set the current directory to the root directory.