I have a perl script that runs a command via rsh and I need to get the exit status of that command on the remote server. The shell on both the local and remote servers is csh (I can't change this). To get the exit status on the remote server I am running:
my $output = `rsh myserver $command;echo $status`
The value of $output is the result of the command but the value of $status is never printed out.
I removed the rsh for testing and got the same results. Here is my test script:
#!/usr/local/bin/perl5.8
use strict;
use warnings;
my $output = `printf '';echo \$status`;
print "$command\n";
print "Returned: $output\n";
And here is the output:
printf '';echo $status
Returned:
If I copy and paste the command from the output into the command line the 0 prints out like I would expect:
:>printf '';echo $status
0
Any idea why this works via the command line but not via perl?