On Jan 26, 2004, at 3:03 PM, mark123 wrote: [..]
[..]
This script telnets into a telnet server (cisco) then telnets into other
cisco router to grab there configs. I get these errors when trying to
connect to certain routers (5, 11,12,13,14). If I look in my dump logs I see
that the device didn't echo anything back. I have play with some control and
break commnads wich help but doesn't fix all of them. I have a feeling it
has something to so with the filehandle or buffer but not sure.
Either case can anyone tell me why I am getting Bad file descriptor at line
94 ?? I have the line marked ****
This is my first perl script so please don't laugh ;-(
use Net::Telnet::Cisco; $session = Net::Telnet::Cisco->new( Host => $host, Dump_Log => "c:/perl/bin/".$filename, Input_log => "c:/perl/bin/".$file, Timeout => $secs);
[..]
[..]use Net::Telnet::Cisco; $session = Net::Telnet::Cisco->new( Host => $host, Port => $port, Dump_Log => "c:/perl/bin/routerdump".$line.".txt", Input_log => "c:/perl/bin/router".$line.".txt", Timeout => $secs, Errmode => sub { #print "\n\n!!Bad command ? ". "port: $port!!!!! $! \n"; $error = $error + 1; # 1 means error has occurred. warn $!; # option are die return and warn ***THIS IS LINE 94 ************* } );
First off, you will want to become good friends with
a. 'use strict' and 'use warnings' b. only putting that use Foo::Bar once.
The error around line 94 could be one of several problems. Those of course will be easier to identify once one has started to sort out which variables in the problem are not a part of the problem.
I presume that you have read the POD for both Net::Telnet Net::Telnet::Cisco
Your comment notes the options as 'die', 'return' and 'warn' and yet you are using a specific piece of there....
You might want to try say
sub my_cisco_err_handler { $error = $error + 1; # 1 means error has occurred. warn $!; }
use Net::Telnet::Cisco; $session = Net::Telnet::Cisco->new( Host => $host, Port => $port, Dump_Log => "c:/perl/bin/routerdump".$line.".txt", Input_log => "c:/perl/bin/router".$line.".txt", Timeout => $secs, Errmode => \&my_cisco_err_handler );
You might also find a better place to write your Dump_log and hence also where you are puttng your Input_log to read from and put those in variables as well...
ciao drieux
---
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>