Fellow monks,

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.


In reply to Executing a script from within a script by gri6507

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.