in reply to How to do system calls in cgi programs

A few points to consider.

Your CGI program will be running in cgi-bin so make sure that Kreports.plx resides in that directory. If it doesn't you'll have to provide the full path:
my $reportProg = "/some-path-to/Kreports.plx";
Make sure that the user running your CGI prog has permission to actually run Kreports.plx. Make sure that Kreports.plx actually works - i.e does it run without errors or problems in a non CGI environment?

Last but not least, make sure you always check the return value from a system call as that could give you some rather handy info as to why Kreports.plx is not running (returns 0 on success, 1 on failure):
my $reportProg = "/some-path-to/Kreports.plx"; system($reportProg) && do { my $errorMsg = "Could not run $reportProg - $!\n"; # your additional error handling code here };
-- vek --

Replies are listed 'Best First'.
Re: Re: How to do system calls in cgi programs
by Anonymous Monk on Jan 04, 2003 at 17:01 UTC
    Kreports.plx runs correctly from the command line in both the cgi-bin and back in it's own directory. It uses absolute paths so in will run anywhere. The courious thing is that the check for return value doesn't produce anything. Ths cgi script runs but no result from system() either way and no reports.
    sub runReports { print "Generating Reports for $script_to_call\n"; my $exit_val = system($script_to_call); if ( $exit_val ) { print "<p>System call failed with an exit value $exit_val\n"; print "<p>Let's see what a backtic exec shows us\n"; print '<pre>', `$script_to_call`, '</pre>'; } else { print "<p>Look for reports in /home/donfox/BioDataProject/kim/Re +ports"; } }
      Are you getting a </html> tag at the end of the page ?. If not, check the Apache error_log.
      poj
      Is Kreports.plx silently failing perhaps? Remember that the user running your CGI prog will be the same user that is running Kreports.plx. Does that user (e.g nobody) have permission to create a file in /home/donfox/BioDataProject/kim/Reports?

      Seeing as we don't know what Kreports.plx is actually doing, make sure that it can run successfully on the command line as the same user that runs your CGI prog.

      Update: Obviously you will not be able to run Kreports.plx on the command line as user 'nobody' but you should still check to see if user 'nobody' has permission to do all the things Kreports.plx will need to do when generating the reports.

      -- vek --