Why am I getting syntax error in backticks even if it works in terminal?

I am trying to run a Linux command in Perl using backlinks. It works when I run it directly on Linux, but when Perl does this via backlinks, 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`; 

It would be very helpful to understand what might cause this error.

thanks

+7
linux perl backticks
source share
1 answer

You probably checked your code on the command line with bash , but you try to run it through sh when you call it with Perl.

Either change your command to Bourne shell compatibility, or explicitly call bash .

+10
source share

All Articles