系统集成系统维护

aix如何根据pid查看端口

aix如何根据pid查看端口?
参与22

15同行回答

jiaxu2000jiaxu2000系统工程师沈阳医学院附属中心医院
http://www.ixbrian.com/blog/?p=70#!/usr/bin/ksh print "Port            PID              Process" netstat -Aan | grep LISTEN | awk '{print $1 " " $5}' | while read...显示全部
http://www.ixbrian.com/blog/?p=70
#!/usr/bin/ksh
print "Port            PID              Process"
netstat -Aan | grep LISTEN | awk '{print $1 " " $5}' | while read pcb port; do
        out=`rmsock $pcb tcpcb`
        if echo "$out" | grep "Kernel Extension" > /dev/null; then
                printf "%-15s Kernel Extensionn" "$port"
        else
                pid=`echo "$out" | sed -n 's/.*pro[c]*ess ([0-9][0-9]*) .*/1/p'`
                if [ -n "$pid" ]; then
                        proc=`ps -p $pid | tail -n 1 | awk '{print $4}'`
                        printf "%-15s %-16s $procn" "$port" $pid
                else
                        echo "Error, Line not recognized \"$out\" for Port $port"
                fi
        fi
done

lslisten.png

收起
事业单位 · 2015-04-03
浏览6208

    提问者

    mayaxing
    系统运维工程师南天软件
    擅长领域: 服务器灾备中间件

    相关问题

    相关资料

    相关文章

    问题状态

  • 发布时间:2015-04-03
  • 关注会员:1 人
  • 问题浏览:17009
  • 最近回答:2015-04-21
  • X社区推广