in reply to Re: system command has problem with '>>'
in thread system command has problem with '>>'

Not true. The shell processes '>>', not 'ls', as can be seen from the pastes below.
Anyone else have any ideas on this?

$ rm aa
$ ls example_file.txt >> aa
$ cat aa
example_file.txt
$ ls exam*
example_file.txt
$ ls example_file.txt >> aa
$ cat aa
example_file.txt
example_file.txt
  • Comment on Re^2: system command has problem with '>>'

Replies are listed 'Best First'.
Re^3: system command has problem with '>>'
by Anonymous Monk on Mar 30, 2010 at 00:45 UTC
    Not true. The shell processes '>>', not 'ls', as can be seen from the pastes below.

    Thats what I said.

    Anyone else have any ideas on this?

    Like I said, use IPC::System::Simple systemx, it process >> like the shell without invoking the shell, or like JavaFan said, invoke the shell

      it process >> like the shell without invoking the shell

      No.

      $ dir foo ls: foo: No such file or directory $ perl -MIPC::System::Simple=systemx -e'systemx "ls", ">>", "foo"' ls: >>: No such file or directory ls: foo: No such file or directory "ls" unexpectedly returned exit value 2 at -e line 1 $ perl -MIPC::System::Simple=systemx -e'systemx "ls >> foo"' "ls >> foo" failed to start: "No such file or directory" at -e line 1 $ dir foo ls: foo: No such file or directory

      Same goes for 2>&1

      $ perl -MIPC::System::Simple=systemx -e'systemx "ls 2>&1"' "ls 2>&1" failed to start: "No such file or directory" at -e line 1 $ perl -MIPC::System::Simple=systemx -e'systemx "ls", "2>&1"' ls: 2>&1: No such file or directory "ls" unexpectedly returned exit value 2 at -e line 1

      It would defy the entire point of systemx if any argument was treated specially.