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

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.

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

    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.

        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.