new netstat script

This commit is contained in:
Oliver Ladner 2015-03-26 19:56:11 +01:00
commit 8cd6159c4a

12
netstat.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
#
# ugliest netstat pwnage.
MY_UID=$(id -g)
if [ $MY_UID -gt 0 ]; then
echo "You must be root, running limited version without -p"
netstat -tlen | grep LISTEN | awk '{print $4}' | sed 's/:::/:/g' | cut -d ":" -f2
else
netstat -tlpen | grep LISTEN | awk '{print $4 ":" $9}' | sed 's/:::/:/g' | cut -d ":" -f2-3 | sed 's/\//:/g' | cut -d ":" -f1,3
fi