2016-04-28 63 views
2

我有我的Linux 64位运行一个Perl脚本,它看起来像这样:perl的执行,其中输入来自<(CMD2输入)命令

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

这工作在bash,但是当我尝试执行相同的命令作为Perl脚本中的反引号,它会抱怨:

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

任何想法?

+1

我知道你有一个解决方案了,但请你会运行'perl -MConfig -E'say $ Config {sh}''并报告输出结果是什么? – Borodin

回答

5

我猜你/bin/sh不会链接到bash,试试:

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

你可以查阅一下/bin/sh链接到与:

% ls -l /bin/sh 
lrwxrwxrwx 1 root root 4 Apr 5 07:03 /bin/sh -> dash 
+0

不错,简单。有用! – 719016

+1

@ 719016我很高兴它为你工作。你可以考虑使用:'/ my/cmd2 input |/my/cmd option1 option2'如果你想支持POSIX shell。 – andlrc