Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to run a Linux command in Perl using backticks. It works when I run it directly in Linux, but when Perl does it through backticks, I get this error:

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

The line of code in question is:

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

Any insight as to what might cause this error would be greatly appreciated.

Thanks

like image 939
user3307598 Avatar asked Nov 15 '16 14:11

user3307598


1 Answers

You probably tested your code on the command line with bash but you're trying to run it via sh when you invoke it from Perl.

Either change your command to be compatible with the Bourne shell, or invoke bash explicitly.

like image 103
Paul R Avatar answered Oct 09 '22 07:10

Paul R