Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Perl won't run command with "|&"

by ikegami (Pope)
on Sep 19, 2013 at 23:06 UTC ( #1054919=note: print w/ replies, xml ) Need Help??


in reply to Perl won't run command with "|&"

Perl uses /bin/sh. It would be useless if the syntax of the command had to vary based on what shell a user used on a particular day.

You could always run csh from sh.

use String::ShellQuote qw( shell_quote ); my $cmd = shell_quote('csh', '-c', 'wget http://... |& tee ...'); my $result = `$cmd`;

Or avoid you can use the multi-arg open-pipe syntax to avoid sh and run csh directly.

my $cmd = 'wget http://... |& tee ...'; open(my $pipe, '-|', '/bin/csh', '-c', $cmd) or die $!; my $result; { local $/; $result = <$pipe>; }

Or you can adjust for sh.

my $cmd = 'wget http://... 2>&1 | tee ...'; my $result = `$cmd`;


Comment on Re: Perl won't run command with "|&"
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2014-07-13 05:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (246 votes), past polls