#!/usr/bin/perl -w use strict; use Net::Telnet; die "Required argument missing!\n" unless ($ARGV[0]); my $target = $ARGV[0]; my $password = "password"; my $telnet = new Net::Telnet (Timeout => 60, Errmode => 'die', Telnetmode => '1', Input_log => "$target.txt", Dump_log => "dump_log.txt"); $telnet->open(Host => $target, Port => '23') || die "Cannot open telnet connection to $target"; $telnet->print($password) if ($telnet->waitfor('/Password:/')); $telnet->print('ena') if ($telnet->waitfor('/\>/')); $telnet->print($password) if ($telnet->waitfor('/Password:/')); $telnet->print('sh run') if ($telnet->waitfor('/#/')); while (1) { if ($telnet->waitfor('/--More--/')) { $telnet->print(chr(32)); }else{ print "Configuration file for $target has been successfully saved!\n"; exit(0) } }