These examples assume you are using Windows 7 and have Cygwin installed with the awk
package.
This single command will identify the process listening on port "2222" by feeding netstat
output into tasklist
using gawk
.
netstat -aon | gawk ' $2~/:2222/ { system("tasklist /svc /FI \"PID eq " $5 "\"") } '