On Sat, Feb 23, 2002 at 02:13:27PM +0530, Veeraraju_Mareddi wrote:
> Please see the code here. But This program terminates if one of
> them is Failed.
It terminates because Net::Telnet->Errmode defaults to 'die'.
You should really set it to 'return'.
But there are lots of other bugs in your code...
> Is there any way to get it done.
sure:
> --------------------------------------------------------------------
> use Net::Telnet;
> $telnet = new Net::Telnet(Port => 25);
^ insert ,Errmode=>'return'
before the closing bracket
> $result ='Active';
move this line to the top of the loop block, otherwise the first
negative server would affect all later ones.
> @hosts=('208.220.254.1',208.220.254.2',208.220.254.3');
insert single quotes ^here and ^here
> foreach $host(@hostes){
^ delete one letter e here
> $telnet->open($host) or $result ='Not Active';
> print " 25 port on $host is $result\n";
> }
> $telnet->close;
move this line at bottom of the loop block
> --------------------------------------------------------------------
Summarizing, what you get is:
use Net::Telnet;
$telnet = new Net::Telnet(Port => 25, Errmode=>'return',Timeout=>1);
@hosts=('208.220.254.1','208.220.254.2','208.220.254.3');
foreach $host(@hosts){
$result ='Active';
$telnet->open($host) or $result ='Not Active';
print " 25 port on $host is $result\n";
$telnet->close;
}
--
Johannes Franken
Professional unix/network development
mailto:[EMAIL PROTECTED]
http://www.jfranken.de/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]