1.将本机连接1521的本机端口找出来,并写入到port.txt文件【 针对AIX的netstat提取】:
netstat -an|grep 1521|awk '{print $4}' |awk -F "." '{print $5}'>>port.txt
2.将lsof得到的PID写入文件PID.txt
for i in `cat port.txt`
do
/opt/freeware/sbin/lsof -i:$i|awk '{print $2}'|grep -v PID >>PID.txt
done
3.通过PID找出运行的程序
for i in `cat PID.txt`
do
ps -ef|grep $i|grep -v grep|awk '{print $10,$11,$12,$13,$14,$15,$16,$17,$18}'
done
==============AIX==============查看本地连接远程1521端口的程序
合成一个脚本文件:
#/usr/bin/shell
netstat -an|grep 1521|awk '{print $4}' |awk -F "." '{print $5}'>>port.txt
for i in `cat port.txt`
do
/opt/freeware/sbin/lsof -i:$i|awk '{print $2}'|grep -v PID >>PID.txt
done
for j in `cat PID.txt`
do
ps -ef|grep $j|grep -v grep|awk '{print $1,$2,$10,$11,$12,$13,$14,$15,$16,$17,$18}'>>program.txt
done
===============================
==============Linux==============
针对Linux的netstat提取:
netstat -an | grep 1521 | awk '{print $4}' | awk -F ":" '{print $2}'
查看本地
打开本地1521端口的程序:
可以合并成一个脚本:
#/usr/bin/shell
netstat -an | grep 1521 | awk '{print
$4}' | awk -F ":" '{print $2}' >>port.txt
for
i in `cat port.txt`
do
/usr/sbin/lsof -i:
$i | awk '{print $2}' | grep -v PID >>PID.txt
done
for
j in `cat PID.txt`
do
ps -ef|grep
$j | grep -v grep | awk '{print $1,$2,$10,$11,$12,$13,$14,$15,$16,$17,$18}'>>program.txt
done
查看本地
打开远程1521端口的程序
netstat -an|grep 1521|awk '{print
$5}' | awk -F ":" '{print $2}'
for i in `cat port.txt`
do
/usr/sbin/lsof -i:$i | awk '{print $2}' | grep -v PID >>PID.txt
done
for j in `cat PID.txt`
do
ps -ef|grep $j | grep -v grep | awk '{print $1,$2,$10,$11,$12,$13,$14,$15,$16,$17,$18}'>>program.txt
done
阅读(2736) | 评论(0) | 转发(0) |