繁体   English   中英

为什么我在反引号中会出现语法错误,即使它在终端中有效?

[英]Why do I get a syntax error in backticks, even though it works in terminal?

我试图使用反引号在Perl中运行Linux命令。 它在我直接在Linux中运行时有效,但是当Perl通过反引号执行时,我收到此错误:

sh: -c: line 0: syntax error near unexpected token `>'
sh: -c: line 0: `(/src/storageUtil --diagnostic 2> >(tee >(cat >&2) >&1)) > log.txt'

有问题的代码行是:

$output = `(/src/storageUtil --diagnostic 2> >(tee >(cat >&2) >&1)) > log.txt`;

任何可能导致此错误的见解都将非常感激。

谢谢

您可能在命令行上使用bash测试了代码,但是当您从Perl调用它时,您尝试通过sh运行它。

更改命令以与Bourne shell兼容,或显式调用bash

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM