TestPort 1.0 用perl写的来测试端口的小程序

TestPort 1.0  用perl写的来测试端口的小程序
By pchoer 03/24/2006

这个程序是一直测试某IP的某个端口的关/闭情况的,类似于ping IP -t。(ping是对IP,我这个是对port)。
因为在实际应用中,有时会用到这样的功能,所以写了这个小程序,测试时方便些。      
 Usage:tp.exe host port
    Exp:tp.exe 192.168.0.1 80

代码如下::

#!/usr/bin/perl -w
#TestPort 1.0
#By pchoer 03/24/2006;

use IO::Socket;
use Net::Ping;

if (@ARGV != 2) {
 print "TestPort 1.0 /nBy pchoer 03//24//2006/n";
 print "/n/tUsage=>$0 host port/n";exit 1;
    }
else
{
 chomp($ARGV[0]);chomp($ARGV[1]);
    $host=$ARGV[0];$port=$ARGV[1];
$p=Net::Ping->new();$alive=$p->ping($host);
if ($alive) {
 print "TestPort 1.0 /nBy pchoer 03//24//2006/n";
  again:
  $sock=IO::Socket::INET->new(PeerAddr=>$host,PeerPort=>$port,Timeout=>30);

  if ($sock) {
   print "/n$host:$port is 【Open】.";close $sock;
   select undef,undef,undef,1;
            }
  else
  {
  print "/n×××××/[$host:$port is Close!/]";
  }

  goto again;
 }#alive

else {

print "/nError::Can't Connect $host!!Please Make Sure $host is availability./n";exit 1;
}

}

软件下载:http://www.06second.com/pchoer/soft/tp.rar

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值