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

ok lets say i have an html form with the action being test.pl test .pl executes fine dumping back out to the browser whatever html i choose. but while test.pl is being executed i want it to run test2.pl just an executable perl program how can i do this?

Replies are listed 'Best First'.
Re: Calling a perl script from cgi
by little (Curate) on Mar 10, 2001 at 22:28 UTC
    Hi Gremlin,

    inside your test.pl you could use:
    @response = `perl test2.pl`; # but then test2.pl has to send its output to STDOUT, so # don't redefine STDOUT targetting to afile or so # and note that if it dies or throws warning that they # are part of that response
    or you use cgi.pm and send aredirection header to the client targetting to the url where your test2.pl resides.

    Have a nice day
    All decision is left to your taste
Re: Calling a perl script from cgi
by Malkavian (Friar) on Mar 10, 2001 at 21:07 UTC
    Could it be that fork is the answer to your problems?

    Malk.
Re: Calling a perl script from cgi
by bladx (Chaplain) on Mar 10, 2001 at 21:11 UTC
    I'm not really a Perl expert yet, so please bear with me if my advice on this question is irrelevant, or worthless ^_^ I'm just trying to help ya out, Gremlin ^_^! Ok, well, I think the way to run it (at least the super basic way to run another script from that one,) would be simply using subroutines to call that next script as the example below shows:

    while ( ... 'whatever here' eq 'whatever') { #all you would have to do is have a pointer to that next .pl file + you want to call, have a subroutine in that other file that you can +call from this one. All of this is without using CGI.pm, but that's +ok, since this is just basic stuff, later you can learn about that if + you want to. doThisSubroutine; #this would call the sub that has your next fi +le pointer }


    Hopefully I understood your question correctly... if not please let me know, so I can know how to answer your question better!! ^_^ Hope this helps!

    bladx ~ ¡muchas veces tengo preguntas!