Hi the problem will most probably be that you need the full path to your script. It should definately work if you call it like:

system( "/usr/bin/perl /full/path/to/the/script.plx" )

You are not bothering checking the return code (should be 0 if no error ) I am assuming an 0755 permissions mask (remember your CGI runs as user 'nobody' or 'apache' rather than user 'you' so it needs permissions to exec).

With your code you are using both the OO and the method call interface from CGI.pm - I have modified it to use just the method interface and have cleaned up the logic for you.

#!/usr/bin/perl -wT $|++; use strict; use CGI qw(:standard); # important shortcuts use Fcntl qw(:flock); # imports LOCK_EX, LOCK_SH, LOCK_NB my $timestamp = localtime; # this should be as suggested above "/usr/bin/perl /path/to/Kreports.p +lx" my $script_to_call = "./Kreports.plx"; $TITLE = "Kim's Report Generator"; $LOGFILE = "/usr/tmp/KreportLog"; print header,start_html($TITLE),h1($TITLE); if ( param('name') ) { # if we have a name we must have been called from our form if ( ( param('name') eq 'Kim' ) and ( param('passwrd') eq 'Knecht' + ) ) { &runReports(); } else { print "Unauthorized!\n"; } } else { # no name param so show form print hr, start_form; # hr() emits a horizontal rule: <HR> print p( $timestamp ); print p( "User ID:", textfield( -NAME => "name" ) ); print p( "Passwrd:", password_field( -NAME => "passwrd")); print p( submit( "send" ), reset( "clear" ) ); print hr; print end_form; } ##### Subs ##### sub bail { my $error = "@_"; print h1("Unexpected Error"), p($error), end_html; } sub runReports { print "Generating Reports\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>'; } }

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: How to do system calls in cgi programs by tachyon
in thread How to do system calls in cgi programs by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.