use Net::Cisco; use Net::Telnet(); # consider: use strict; $t =Net::Telnet::Cisco->new(Host=>'$ip'); # doesn't work: '$ip' -> $ip (BTW: where is $ip defined?) print "connected"; # a bold statement w/o any test (e.g. checking $t) $t->login('', ''); $t->cmd("telnet 192.168.201.3"); # failure? success? no check here $k=Net::Telnet->new(Timeout=>10,Errmode=>'die'); # You are opening a second session from localhost! # Try to do the $k-stuff from within the $t-session. $k->open("192.168.201.3")or die "$k->errmsg"; print "connected"; # see above $k->waitfor('password:$/i'); $k->print("public"); $k->waitfor('>$/i'); @output=$k->print("show system"); open(CONFIG,">config.txt"); # three argument open + check would be nice print CONFIG "@output\n"; close(CONFIG); $k->close; $t->close;