Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: Running Multiple Commands using System

by dkhoriya (Initiate)
on Jun 27, 2014 at 07:00 UTC ( [id://1091437]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Running Multiple Commands using System
in thread Running Multiple Commands using System

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.
  • Comment on Re^4: Running Multiple Commands using System

Replies are listed 'Best First'.
Re^5: Running Multiple Commands using System
by Corion (Patriarch) on Jun 27, 2014 at 07:06 UTC

    Maybe I did not make myself clear enough.

    What I wanted to clarify is, whether the string you pass to system would work on its own when typed into a terminal.

    So, again my question, maybe more explicit:

    After opening a plain terminal, with your normal shell running, does pasting the following command work?

    sdb -d root on 'sdb -d shell; ls';

    If that doesn't work without Perl, it won't work with Perl added either.

    If you want to run multiple commands within one shell session, I recommend creating a shell script and launching that script via system.

      Okay. Thanks for your elaborate explanation. But
      system("sdb -d root on 'sdb -d shell; ls'");
      the syntax used here is what I found to run multiple commands of shell by one system call. But only in this specific case it does not work.
      system("sdb -d root on 'sdb -d shell; cd /opt; ls';bash ");
      gives error of "root does not take more than one arguement" while the following system call runs fine.
      system("sdb -d shell 'cd /opt; ls';bash ");
      executing all the 3 shell commands sequentially in one child terminal. and running independently
      system("sdb -d root on");
      also works fine.

        So, your problem is with the sdb program. It says that "sdb root" does not take more than one argument. But you are giving it two arguments, on and 'sdb -d shell; cd /opt; ls'. I'm pretty confident that your command line as you show it to us does not work outside of Perl either.

        This is not a Perl problem but a problem with the sdb program. I suggest you consult the documentation of the sdb program and/or ask the vendor of the program on how to proceed.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2024-04-23 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found