719016 719016 - 2 years ago 70
Perl Question

perl execute a command where input comes from <(cmd2 input)

I have a Perl script that I run in Linux 64bit and it looks like this:

my $ret = `/my/cmd option1 option2 <(/my/cmd2 input)`

This works in bash, but when I try to execute the same command as a backtick in the Perl script, it complains:

sh: -c: line 0: syntax error near unexpected token `('

Any ideas?

Answer Source

I guess your /bin/sh is not linked to bash, try:

my $ret = `bash -c '/my/cmd option1 option2 <(/my/cmd2 input)'`

You can check what /bin/sh is linked to with:

% ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Apr  5 07:03 /bin/sh -> dash
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download