http://qs321.pair.com?node_id=695519


in reply to Using IPC::Run

An important thing to realize is that >tape is not an argument to the program, it's an instruction to the shell. The shell will open up the file tape, and redirect the output of cpio to that file. The command will never see that file on its command line at all.

Many commands that start programs, like system, exec, and IPC::Run::start, if given a list will directly execute the given program with the given arguments, without using the shell at all. Since it's the shell's job to handle output redirection, with no shell it doesn't happen.

It looks like you have one workable solution in your responses already, which is to use IPC::Run's speicial syntax for output redirection, something like IPC::Run::run \@cmd, '>', $tape. The docs say you can also pass a single string to IPC::Run::run, which will be passed to the shell, so IPC::Run::run("/bin/cpio -ov >$tape") might also work. Finally, for something so simple, consider just system.

Hope this helps!