Yeah, that was the next problem. At first I was using the backticks, but the problem was that the utility script took 20 or so minutes to run, and the backtick operator only returns after the child process has stopped running, so the operation timed out from the browser. I of course was using a nohup to keep the utility script running on the server, but the end user would see it as an error...

I implemented the open method after that, and it works beautifully :)

Final, working code (minus sensitive info):

...........................
#!/opt/perl5/bin/perl -w use strict; use CGI; # set path, instead of putting it in the open statement $ENV{'PATH'} = "/usr/bin:/opt/perl5/bin/:"; #location of product_gen.pl, plus arguments my $gen_script = "/path/to/server/product_gen.pl -prfv"; # Create a new CGI object my $cgi = new CGI; # Output HTML header to browser print $cgi->header('text/html'); print qq{<h4>script executing</h4>}; open(PRODUCT_GEN, "nohup perl $gen_script |") or die "Error: $!\n"; while (<PRODUCT_GEN>) { print $_, "<br>"; } close(PRODUCT_GEN);
...........................

Thanks again for all the assistance!

  higle

In reply to Re: Re: Re: Re: Executing another script from a CGI by higle
in thread Executing another script from a CGI by higle

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.