In the following command which I execute in a Perl script, how do I capture stderr?
my $output = `ssh login.com git clone --bare user@login.com:/nfs/repo/ /nfs/repo//4124/`;
if ($? ne '0')
{
$stderr = $output;
print $stderr;
}
else
{
$stdout = $output;
print $stdout;
}
The
2>&1at the end sends standard error to the same place as standard output, which is captured by the back-quotes.