Created
June 5, 2017 08:57
-
-
Save yesmeck/be0537e9515399c9e6916530dbf43c76 to your computer and use it in GitHub Desktop.
detect which command using port
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
port=$1 | |
pid=`lsof -i :${port} -P -t -sTCP:LISTEN` | |
dir=`lsof -p ${pid} | awk '$4=="cwd" {print $9}'` | |
cmd=`ps -o command -p ${pid} | sed -n 2p` | |
echo "${cmd} in ${dir}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment