M
madhadder
Hello All
I have inherated a perl script that checks cisco devices by telneting
to them
and running commands who's output is captured and emailed out. The
problem
I have is that if for whatever reason a device is not reachable the
script dies instead
of continuing with the rest of the devices in the list, and me being a
total Perl novice
I cant figure it out and have given up after 3 days of trying..
What I would like for the script to do is to add a line to the Log file
stating that xxxx
device was not accessable, and to continue with the rest of the
devices. Is this possible?
Below is a sample of the Orig. Unmodified script that does the
checking. It currently works
100%, unless the the device isn't reachable..
Example:
foreach $device(@devlistsslo) {
open (logfile,">>temp/ssl.log");
print logfile "==== $device
============================================\n";
chomp($device);
$prompt=uc($device).">";
$session=telnet->new (Timeout => 20,
Prompt => "/$prompt/");
$session->open($device);
$session->waitfor('/Password:\s/') || die;
$session->print($enablepwd2);
$session->waitfor('/>/') || die;
@output=$session->cmd($cmd12);
print logfile "";
print logfile "";
print logfile "@output ";
close logfile;
# Close session
$session->print("quit");
$session->close;
Thanks
I have inherated a perl script that checks cisco devices by telneting
to them
and running commands who's output is captured and emailed out. The
problem
I have is that if for whatever reason a device is not reachable the
script dies instead
of continuing with the rest of the devices in the list, and me being a
total Perl novice
I cant figure it out and have given up after 3 days of trying..
What I would like for the script to do is to add a line to the Log file
stating that xxxx
device was not accessable, and to continue with the rest of the
devices. Is this possible?
Below is a sample of the Orig. Unmodified script that does the
checking. It currently works
100%, unless the the device isn't reachable..
Example:
foreach $device(@devlistsslo) {
open (logfile,">>temp/ssl.log");
print logfile "==== $device
============================================\n";
chomp($device);
$prompt=uc($device).">";
$session=telnet->new (Timeout => 20,
Prompt => "/$prompt/");
$session->open($device);
$session->waitfor('/Password:\s/') || die;
$session->print($enablepwd2);
$session->waitfor('/>/') || die;
@output=$session->cmd($cmd12);
print logfile "";
print logfile "";
print logfile "@output ";
close logfile;
# Close session
$session->print("quit");
$session->close;
Thanks