1

Trying to run perl system command with a full blown shell environment. Similar to Python's Popen with shell=True. Tried system('/bin/bash -c "something"') and that didn't work. Someone hook a non-perl guy up!

--- update ---

# ./test.pl 
ENV-PATH: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
sys-PATH: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
CarpeNoctem
  • 5,540
  • 8
  • 30
  • 33
  • 1
    Perl `system` already runs the command through a shell unless you call it with more than one argument. Read the [docs](http://search.cpan.org/perldoc?perlfunc#system). – salva Jul 29 '11 at 11:18

2 Answers2

0

What happens with:

my $rc = system "/bin/bash", "-c", "shell command to run with arguments";
if ($rc != 0) {print "command failed: $?";}
glenn jackman
  • 238,783
  • 38
  • 220
  • 352
0

So it appears that if you use the system() command it doesn't truly invoke a shell unless a shell meta character is seen OR the arg is in the form of a scalar. So system("echo real shell") works in my case but not system("echo", "real", "shell").

CarpeNoctem
  • 5,540
  • 8
  • 30
  • 33