http://www.perlmonks.org?node_id=989704


in reply to How to pass form data from a CGI script to its child process?

I surely would have to write code which encodes the form data for the command line (all character sequences which might be treated specially by the shell would have to be transformed), and the form data might be very long, even longer than the maximum length which is allowed for a command line.

You could use CGI

SAVING THE STATE OF THE SCRIPT TO A FILE: $query->save(\*FILEHANDLE)
and reading it
my $q = CGI->new(\*IN);
so when you use the list form of system, system $^X, 'scriptB.pl', 'some/file/something';

Replies are listed 'Best First'.
Re^2: How to pass form data from a CGI script to its child process?
by Nocturnus (Beadle) on Sep 05, 2012 at 07:31 UTC

    Thank you very much for your reply.

    I just did not know that the CGI module is able to do that. In the past, I have used the CGI module heavily and thought that I would know the most important things about it, but this obviously was an error.

    I have tested your proposition, and it works great. But now, there was the problem how to tell script B.pl from where it should read the parameters (HTTP form data or file / STDIN). That was easy to solve, though:

    A.pl will call B.pl with an additional command line parameter. If B.pl finds this command line parameter when called, it knows that it has been called from another script and that it should read STDIN for the CGI data; otherwise, it knows that it has been called directly from the user's browser and that it should read the CGI data from the HTTP data.

    Thanks again,

    Nocturnus