GS has asked for the wisdom of the Perl Monks concerning the following question:
My script terminates if it can not telnet to the host in the array and does not loop through rest of the hosts in the array. How do I force it to continue to other hosts if it fails to telnet one host. here is the script:
use Net::Telnet; @hosts = ("ncc1","ncc2","ncc3") for ($x=0; $x <= $#hosts; $x++) { $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die'); $telnet->open("$hosts[$x]"); $telnet->login('test', 'testuser'); my @arr = $telnet->cmd('ifconfig -a'); $telnet->close("$host"); print "\n Probe - $host \n"; print "\n @arr \n" ; }
Edit by castaway - fix code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::Telnet
by davidj (Priest) on Jun 22, 2004 at 18:46 UTC | |
|
Re: Net::Telnet
by gri6507 (Deacon) on Jun 22, 2004 at 20:27 UTC |