Domů | Blogy | Blog uživatele kamilhlavka

Perl telnet reboot linux

#!/usr/bin/perl

#Reboot modemu v PERL u
#knihovna http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm
# telnet.pm do lib perlu

use Net::Telnet;

# Create our Telnet object
my $telnet = new Net::Telnet (
Timeout => 20,
#Prompt => '/bash\$ $/'
);

# Have our object connect to our remote server
$telnet->open("192.168.0.1");

# Login as myusername with mypassword
$telnet->login('root', 'xxxxx');
my @lines = $telnet->cmd('reboot');

print join('', @lines) . "\n";

#$telnet->close;