On 09/12/2011 09:50 AM, Alan Bryant wrote:
Does anyone have anything already, or prefer a specific SSH module
over the others?


Quick 'n dirty...

#!/usr/bin/perl

use Net::SSH::Perl;

my $host = '10.0.0.1';
my $user = 'admin';
my $pass = 'pass';
my $cmd = '/system resource print';

my $ssh = new Net::SSH::Perl($host);
$ssh->login($user, $pass);

my ($stdout, $stderr, $exit) = $ssh->cmd($cmd);

print "stdout: $stdout\n";
print "stderr: $stderr\n";
print "exit: $exit\n";


FYI, Net::SSH::Perl supports RSA authentication and works with RouterOS. You'll also probably want to wrap the login and cmd calls in an eval block and trap authentication or other spurious errors if this is for something non-interactive.

Regards,

--
Kristian Hoffmann
System Administrator
[email protected]
http://www.fire2wire.com

Office - 209-543-1800 | Fax - 209-545-1469 | Toll Free - 800-905-FIRE

_______________________________________________
Mikrotik mailing list
[email protected]
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS

Reply via email to