Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Running Multiple Commands using System

by Corion (Patriarch)
on Jun 26, 2014 at 10:22 UTC ( [id://1091326]=note: print w/replies, xml ) Need Help??


in reply to Running Multiple Commands using System

Have you printed the actual string that you are passing to system?

my $cmd= 'sdb -d root on'; system($cmd)== 0 or die "Couldn't launch [$cmd]: $! / $?";

Most likely there is some (lack of) shell quoting going on, but it's hard to say without seeing the relevant parts of your code.

Replies are listed 'Best First'.
Re^2: Running Multiple Commands using System
by dkhoriya (Initiate) on Jun 27, 2014 at 06:49 UTC
    Update: I am not using just a single shell command in System but multiple.
    system("sdb -d root on");
    works fine but using multiple commands in single system call like
    system("sdb -d root on 'sdb -d shell; ls'; ");
    doesn't work.

      Does using multiple commands work outside of Perl?

        system will create a child owning another terminal different from parent and while the execution of command is finished, the handle is returned to the parent. So the question you asked is not relevant here. Outside perl, I can make multiple commands run in series one by one without caring but while running from perl, in the same child terminal I have to execute multiple serial commands. If I use another system call for a second command then a new child terminal is created and the previous handle is gone. Hence no use.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-26 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found