use warnings; use Net::Telnet; my $Telnet = new Net::Telnet; my $InHandle = $Telnet->input_log("input.txt"); my $OutHandle = $Telnet->output_log("output.txt"); my $prmpt = '/[\w().-]*[\$#>:.]\s?(?:\(>\))?\s*$/'; $host="172.16.1.1"; $username = "user"; $password = "pass"; $enpwd = "enable"; my $telnet = Net::Telnet->new( Host => $host, Input_log => "input.log", Output_log => "output.log", Dump_Log => "dump.log", Timeout => 10); # provide host address $telnet->open("$host"); print "\n\n Connecting to $host\n"; # authentication @out = $telnet->waitfor('/Username: $/i') || next; $telnet->print($username); print "@out\n"; # for tshoot only @out = $telnet->waitfor('/Password: $/i') || next; $telnet->print($password); print "@out\n"; # for tshoot only # if enable, send "enable" and enable-pwd unless ($telnet->waitfor('/Username: $/i' | '/#/i')) { #$telnet->waitfor('/>/'); @out = $telnet->print('enable'); print "@out\n"; # for tshoot only @out = $telnet->print($enpwd); print "@out\n"; # for tshoot only } print "username, password, & enable mode authentication accepted-\n"; $telnet->close; #### Connecting to 172.16.1.1 1 1 pattern match timed-out at c:\temp\dirB2D.tmp\testing 3.pl line 35 Press any key to continue . . . Connecting to 172.16.1.2 pattern match timed-out at c:\temp\dirEDA1.tmp\testing 3.pl line 26 Press any key to continue . . .