根据端口查询程序进程路径
- #!/bin/bash
- ##########################################################################################
- #### The input port returns the program process path ####
- ##########################################################################################
-
- PID=$(netstat -nlp|grep :$1|awk '{print $7}'|awk -F"/" '{ print $1 }')
- DIR=$(/usr/bin/pwdx $PID)
- FILTERDIR=$(echo $DIR |awk -F ' ' '{print $2}')
- echo -e "\033[31m The pid of port\033[0m \033[34m$1\033[0m \033[31mis\033[0m \033[33m$PID\033[0m \033[31mand the process path is\033[0m \033[33m $FILTERDIR \033[0m"
-
-