#!/usr/local/bin/perl use strict; use warnings; use constant HOST => ''; use Net::Telnet; use constant TELNET_LOGIN => ''; use constant TELNET_PASSW => ''; use constant TELNET_LOGS => 'telnet.log'; use constant SAVE_CONFIG => 'N';#Saving current user config? Y or N my $telnet = new Net::Telnet( Timeout => 3, Errmode => "return", Output_log => TELNET_LOGS, Input_log => TELNET_LOGS ); $telnet->open(Host => HOST); $telnet->waitfor('/User:/m') ? $telnet->print(TELNET_LOGIN) : ($telnet->close() and die $telnet->errmsg() . "\n"); $telnet->waitfor('/Password:/m') ? $telnet->print(TELNET_PASSW) : ($telnet->close() and die $telnet->errmsg() . "\n"); $telnet->waitfor('/>/m') ? $telnet->print('en') : ($telnet->close() and die $telnet->errmsg() . "\n"); $telnet->waitfor('/#/m') ? $telnet->print('ena') : ($telnet->close() and die $telnet->errmsg() . "\n"); $telnet->waitfor('/Password:/m') ? $telnet->print(TELNET_PASSW) : ($telnet->close() and die $telnet->errmsg() . "\n"); $telnet->waitfor('/#/m') ? $telnet->print('reboot') : ($telnet->close() and die $telnet->errmsg() . "\n"); $telnet->waitfor('/ Saving current user config before reboot\? \(Y\/N\):/m') ? $telnet->print(SAVE_CONFIG) : ($telnet->close() and die $telnet->errmsg() . "\n"); $telnet->waitfor('/ This will reboot (all )?device(s)?\. Continue\? \(Y\/N\):/m') ? $telnet->print('Y') : ($telnet->close() and die $telnet->errmsg() . "\n"); $telnet->close(); print "Reboot...\n";