I need to create a script that will work on CentOS 5.x and CentOS 6.x boxes. CentOS 5.x uses Perl 5.8 and CentOS 6.x uses Perl 5.10. The goal is to be able to ssh into a box, that has a key exchange in place, then run python -V, to determine if the default version is python 2.6.
I'm guessing if I get a script that works with Perl 5.8, that it'll work for 5.10 as well. I made some progress with Net::SSH:Any to have to throw it away, as it looks like it works with Perl 5.12 and newer.
I've tried IPC::System::Simple and qx as well, but haven't had luck capturing the output.
Some of my failed attempts:
Fail 1:
use IPC::System::Simple qw(system systemx capture capturex);
my $output = capture("/usr/bin/ssh root\@10.100.10.56 python -V");
print "out: " . $output . "\n";
Fail 2:
my $output = qx(ssh root\@10.100.10.56 python -V);
print "out: " . $output . "\n";
Fail 3:
my @output = qx(ssh root\@10.100.10.56 python -V);
print "@output\n";
I'm not sure if the call of ssh is playing with anything and am in desperate need of a sanity check. When the command is run, the output is shown on the screen, but not stored in the variable, which I can do substring checks against. The $output variable is left blank. If I'm missing something, please let me know. Thanks :)
python -Vmay write toSTDERRinstead ofSTDOUT. Also, why not just use a different module for SSH likeNet::OpenSSH?SSH,SSH2, andOpenSSH. I've tried to simplify things and just run the command directly to get things working. Is there a way to getqxto capture stderr too?systemwhen there is a pure Perl equivalent.Net::OpenSSHhas this nicesystemmethod that lets you controlSTDIN,STDOUT,STDERR, and more.Net::OpenSSHpasses all tests on CPAN Testers for 5.8.x. I think you're just looking at the license terms, which have nothing to do with whether a module will run on earlier Perl versions.