Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Multiple commands with one system call

by kennethk (Abbot)
on Sep 29, 2011 at 17:02 UTC ( [id://928617]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Multiple commands with one system call
in thread Multiple commands with one system call

Are you sure about that? When I execute:

perl -e 'system("echo 1;echo 2;echo 3")'

I get the output:

1 2 3

Are you interupting execution, with perhaps ^c? In this case, yes, you are killing all jobs simultaneously. You could execute all three by splitting into multiple system calls:

system ("vp -e $ENV{VREL}"); system ("vscmd set-measure-mode fast; vscmd pg-address-check off");

Replies are listed 'Best First'.
Re^4: Multiple commands with one system call
by renzosilv (Novice) on Sep 29, 2011 at 19:49 UTC

    I think when you make the echo call. System calls echo 1 finishes and then calls echo 2. In my case however my first program doesn't finish, I actually have to make the second call while the first one is running. Which is what makes it a bit challenging since the second call will not happen until the first one is done.

      Then at the very least, you need a fork or threads. Depending on some very practical details, I would probably use IPC::Open2 to monitor progress of the child progress so you know when to execute your secondary commands. Some details of interprocess communication are discussed in perlipc.
      if Perl detects any shell meta-characters, it forks-and-exec a shell to handle the command. So you can jam a series of shell commands into your system() call. Note that I said "can", not "this is a good idea." ;)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-18 01:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found