gri6507 has asked for the wisdom of the Perl Monks concerning the following question:
For reasons that I will leave out of this discussion, I have a Perl script (let's call it main.pl) which can execute other slave Perl scripts (let's call one such script doit.pl). The user runs the slave script using the following command: perl path/to/main.pl --script path/to/doit.pl -- --doitArg1=1 --doitArg2 --etc The way main.pl executes the provided script is with a scheme like
my $scriptdir = File::Spec->rel2abs(dirname($doItScript)); push @INC,$scriptdir; unless (my $return = do $doItScript) { croak "could not parse $doItScript: $@" if $@; croak "could not pull in $doItScript: $!" unless defined $return; croak "could not execute $doItScript" unless $return; }
One such slave script (let's call it mojo.pl) is actually a web server using Mojolicious which has some predefined actions brought out into the web browser. I now would like to add a new browser interface where a user can select some other doit.pl script, have it executed within the mojo.pl script, and have the STDOUT displayed in the browser, live updating using a websocket.
The difficulty that I have is that if I use the same do $doItScript scheme within mojo.pl that the single threaded nature of perl's do() function would prevent any concurrent webserver actions needed to do live updates of STDOUT to the browser. Can someone suggest some alternatives?
P.S. I thought about having mojo.pl fork a thread and execute another instance of main.pl to execute the doit.pl. However, one of the restrictions is that I cannot have multiple instances of main.pl running on the server due to shared resource limitations.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Executing a script from within a script (Safe.pm)
by Anonymous Monk on Jan 18, 2014 at 08:22 UTC |