I am trying to redirect the output and error to a file in Unix through a Perl script.
The command is running fine in Unix, but while running the Perl script it is throwing the error sh: & is unexpected
. I tried using escape character also
Command:
`ls -lrt $myfile >>& $output`
Also used Command:
`ls -lrt $myfile >> $output 2>&1` - got ambiguous output redirect error
Backticks use
/bin/sh
. You're trying to redirect STDOUT and STDERR? The syntax is:You also need to convert your file names to shell literals. They might contain spaces, for example, or worse.