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

I'm having trouble to generate the files on the fly by using CGI program. In the cgi program 'download.pl", I use the following code to let the user download the file generated by 'metaStk.pl':
use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); system ("/usr/bin/perl metaStk.pl"); print header("text/plain"), start_html(), (a {href=>'metafile.gz'}, "download data"), end_html();
and start the script from the browser, I get the following result:
"Tue Jul 16 11:02:02 2002:Exiting metaStk.pl Content-Type: text/plain +download data."
Nothing can be downloaded. The 'metaStk.pl' program is supposed to generate a compressed file "metafile.gz" after execution. If I run the program individually, I'm sure I can get the compressed file. But still I can't get what I want from the cgi program. Any suggestion? thanks in advance! yjin

Replies are listed 'Best First'.
Re: system function
by vladb (Vicar) on Jul 16, 2002 at 17:04 UTC
    Hmm,

    Could you verify that the metaStk.pl script doesn't print anything out? I suspect your script may infact be printing the
    Tue Jul 16 11:02:02 2002:Exiting metaStk.pl
    line?



    _____________________
    # Under Construction
Re: system function
by Cine (Friar) on Jul 16, 2002 at 22:56 UTC
    This is not going to work the way you want it to. Your program 'metaStk.pl' will generate the file metafile.gz each time the script is called meaning you wont know which file the user is going to get...

    May I suggest something like this instead:
    print header("application/zip"); system("/usr/bin/perl metaStk.pl");
    where your metaStk.pl now prints the metafile.gz into STDOUT.

    T I M T O W T D I