in reply to Re: Cisco Telnet
in thread Cisco Telnet

i would like if its possible to write in the log file the error form eval in this code. From "perllogrouter/router$i.log"the eval error to be put there if its possible.

eval { my $session = Net::Telnet::Cisco->new(Host => "$device", Input_log => "perllogrouter/router$i.log", ); $session->login(Password => $curpwd); if ($session->enable("$curpwd")) { # Execute a command @output = $session->cmd ('show running-config | section hostname') +; print "@output\n"; print " ======================================================\n"; } $session->close; }; if ($@) {print "Error: $@\n"}

Replies are listed 'Best First'.
Re^3: Cisco Telnet
by mvip (Acolyte) on Aug 27, 2013 at 16:18 UTC

    sorry for the noob questions but i done this. So here it is for shearing

    if ($@) { my $logtext = 'ruterproba.txt'; open my $fh, '>>',$logtext or die "Nemoze da zapise vo $logtext poradi:$! "; print $fh "Error: $@\n"}

    I dont know why i start learning perl, but i have to admit i have finish great jobs with him :)) i love it and im continuing to learn more and more :) and tnx for support .....