dkhoriya has asked for the wisdom of the Perl Monks concerning the following question:

Monks, I am sorry to distract your meditation but I need to have your attention. I am using 'system' call for executing 'some shell' commands via running a perl script. Problem is 'some shell' commands also include a command which takes more than 2 parameters but while executing, the error is, "---- only takes one arguement". In my case, the command is "sdb -d root on" and hence the error is "root only takes one arguement". Please resolve and go back, meditate. Gestures! 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: Running Multiple Commands using System
by Corion (Patriarch) on Jun 26, 2014 at 10:22 UTC

    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.

      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?

Re: Running Multiple Commands using System
by Anonymous Monk on Jun 26, 2014 at 10:39 UTC
      #!/usr/local/bin/perl use strict; use warnings; 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 ");
      and running independently
      system("sdb -d root on");
      also works fine.
Re: Running Multiple Commands using System
by zentara (Cardinal) on Jun 26, 2014 at 11:25 UTC
    he error is, "---- only takes one arguement". In my case, the command is "sdb -d root on" and hence the error is "root only takes one arguement". Please resolve

    Try something like this:

    my @options = ( ' -d root' , 'on'); system ("sdb @options");
    or play with the options till it accepts it. :-)

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      Doesn't work that way. I am definitely a human and I play those who aren't ;-)