Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Run multiple shell commands on the same perl script

by 2teez (Priest)
on Oct 30, 2012 at 22:42 UTC ( #1001570=note: print w/ replies, xml ) Need Help??


in reply to Run multiple shell commands on the same perl script

You can do like so:

use warnings; use strict; for my $cmd(qw(ls ipconfig)){ system("$cmd"); }
NOTE:
  1. Please, check this How do I post a question effectively?

  2. "..When I run the script below, it only picks the first commands.."
  3. Reason and Answer:
    "..The "exec" function executes a system command *and never returns*; use "system" instead of "exec" if you want it to return...."
    Check also exec and system
  4. I used ipconfig instead of the OP ifconfig because I tested this on window OS.
Hope this helps.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me


Comment on Re: Run multiple shell commands on the same perl script
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2015-07-03 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls