-bash-4.1$ cat collect_netstat.pl
####采集端口信息程序
use Data::Dumper;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
$ua->agent("Mozilla/8.0");
if ( $#ARGV < 1 ){
print "Usage perl collect_netstat.pl Ipaddr Port :!\n";
exit(-1);
};
my $ip=$ARGV[0];
my $port=$ARGV[1];
$a=`netstat -nap | grep $port | grep LISTEN |grep ^tcp | awk '{print \$NF}'`;
if ($a=~ /.*?(\d+)\/.*?/sm){
print $1."\n";
$process =$1;
};
print '--------------------------'."\n";
print $process."\n";
@b=`netstat -nap | grep $process | grep ESTAB | grep ^tcp | awk '{if (\$4!~/$ip:$port/) print \$0}'`;
foreach (@b){
$a=$_;
if ($a=~ /.
perl 发送表单数据
![](https://img-home.csdnimg.cn/images/20240711042549.png)