Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Running blocks of shell script from within perl script

by sundialsvc4 (Monsignor)
on Apr 22, 2014 at 20:52 UTC ( #1083231=note: print w/ replies, xml ) Need Help??


in reply to Running blocks of shell script from within perl script

Yes, indeed.   exec, by any other name, can only “execute” one ... “something.”   Therefore, if you want that “one something” to consist of “executing many commands,” you need to persuade “the host, whoever it is ...” to execute “many commands” as “one something.”   :-D   In other words, you need to build some kind of a shell-script.   Construct such a script (if necessary).   Then, make it “executable.”   Then, execute “it,” and gather-up its [combined ...] output.   Q.E.D.

“Perl or not ...” and, pretty much, regardless of operating system, this will be the way that you can get this kind of requirement done.


Comment on Re: Running blocks of shell script from within perl script
Re^2: Running blocks of shell script from within perl script
by marto (Chancellor) on Apr 22, 2014 at 21:30 UTC

    “Perl or not ...”

    There you go again, quoting something that nobody said.

      Please ... just skip it.   Skip the personal jabs and stick to the subject of the thread.   My comment is very clearly meant to say that “in this case it does not matter whether you are using the Perl programming language ... or any programming language ... or not.”   I cannot help but conclude that my intentions were quite clear.

      Hmm.   Site logged me out.   Nearby comment obviously was mine.

        take you own advice, stick to the subject of the thread. Your PEBKAC issue is well known.
Re^2: Running blocks of shell script from within perl script
by lilgreen (Acolyte) on Apr 22, 2014 at 21:32 UTC

    Using this mentality I've got this to work:

    sub exec_check { my (%check) = @_; my $script = './fh.tmp'; open( my $out, '>', $script ); print $out $check{'CHECK_CODE'}; close($out); system("chmod 755 $script"); my @return = qx/$script/; foreach (@return) { my ($status, $string) = split(";", $_); print_output($status, $string); } system("rm $script"); }

    It still seems a bit inelegant, but maybe with as with so many perl things it's just as elegant as it's going to get :\

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1083231]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-08-22 00:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (145 votes), past polls