- 论坛徽章:
- 0
|
#/usr/bin/perl -w
my @list1;
my @A=("192.168.100.1","192.168.100.88","192.168.100.99");
my @port_A=(22,23,25,80,631,111);
for my $A (@A) {
for my $port_A (@port_A) {
push @list1,"$A-$port_A-tcp\t";}
}
foreach my $list1 (@list1) {
@network_list = split(/-/,$list1);
&port_check(@network_list[0],@network_list[1],@network_list[2]);
}
sub port_check {
use IO::Socket::INET;
($host,$port,$proto) = @_ ;
$socket = new IO::Socket::INET(
PeerHost =>$host,
PeerPort =>$port,
Proto =>$proto);# or die "ERROR in Socket Creation : $!\n";
if($socket){
print "check port OK: $host $port $proto \n";
}
else{
print "not found port:$host $port $proto\n";
}
$socket->close();
}
一直报错:
Can't call method "close" on an undefined value at sub.pl
好像是 $socket这个没有定义成功,不知道哪里出错了 |
|