Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Using IPC::Run

by sgifford (Prior)
on Jul 04, 2008 at 05:29 UTC ( #695519=note: print w/ replies, xml ) Need Help??


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!


Comment on Re: Using IPC::Run
Select or Download Code
Re^2: Using IPC::Run
by pc88mxer (Vicar) on Jul 04, 2008 at 07:59 UTC
    Finally, for something so simple, consider just system.
    The point to using IPC::Run is that you can invoke another program with arguments and some I/O-redirection without having anything re-interpreted by a shell. For instance, system("/bin/cpio -ov >$tape") won't work as desired if $tape has a space in it.

    Using the multi-argument form of system allows you to specify a command's arguments without worrying about shell re-interpretation. IPC::Run extends this capability to include simple I/O-redirection. The next step would be the ability to set up complete pipelines of commands without having to use a shell.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://695519]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2014-07-29 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (213 votes), past polls