#!/usr/bin/perl -w use IO::Socket; $host="202.46.24.25"; $port="21"; #$flags=100; while ($port<24) { $remote = IO::Socket::INET -> new ( Proto => "tcp", PeerAddr => $host, PeerPort => $port ) ; if ($remote) { # $remote->recv($line, $flags) or die "Can't recv: $!\n"; # sysread($remote, $line2, 4*1024) or die "couldn't read any data"; # print $remote "test foo \n\n\n"; # print $remote "\^\]\[\n\n\n"; shutdown($remote, 1); # can be 0, 1, 2 @line = <$remote>; close $remote; print "$host:$port=>\tActive\t@line\n"; # print LOG "$host:$port=>\tActive\n"; # push @active_ports, $port; } else { print "$host:$port=>\tInactive\n"; # print LOG "$host:$port=>\tInactive\n"; } $port=$port+1; }