$rt is false (0) after the run
Is it false because there was not output (empty string) or is it
undefined because the command failed to execute at all? In the
latter case, you could print out the system error message to see if it
might provide some hint as to what's going wrong (that would typically
be "No such file or directory", for example, if the command isn't found along the
configured search path):
my $rt = `...your command...`;
print "error: $!\n" unless defined $rt;
Are you running your Perl script from exactly the same command line / environment that you can successfully execute it in without
the backticks wrapper? In cases like these, it's usually best to
start with whatever works, and then modify things in small steps
until it no longer works. For example, you could try to run the command
within backticks from the shell, or run it with system from Perl... both with and without the 2>&1 redirection, etc. — and all from the same command line, to begin with.
If all else fails, you could trace the system calls being made to
get a clearer picture of what's going on, e.g.
$ strace -f ./686679.pl
or, to redirect the output to a file:
$ strace -f -o strace.out ./686679.pl
or, to trace only specific system calls, like execve,
$ strace -f -e execve ./686679.pl
or the set of 'file' system calls, etc.
$ strace -f -e file ./686679.pl
(If you're having difficulties interpreting strace's output,
post the last 20-30 lines here...)
|