Archive for March 16th, 2007

Separa as interfaces e seus IP’s em uma única linha, separados por vírgula!

# SUSE=`grep -i suse /etc/issue`; echo ""; if [ ! -z "$SUSE" ]; then ip a | egrep 'inet [0-9][0-9][0-9].[0-9][0-9][0-9]' | awk -F " " '{if ($7 == "secondary") print $8 "-" $2; else print $7 "-" $2}' | cut -d / -f 1 | sed 's/^/"/g' | sed 's/$/",/g' | sed ':a;$!N;s/\n//;ta;'| sed 's/,$//g' ; echo ""; else IFACE=`ifconfig | grep ^eth | cut -d ' ' -f 1`; for x in $IFACE; do echo -n "\"$x-`ifconfig $x | egrep addr:[0-9][0-9][0-9].[0-9][0-9][0-9]. | awk -F " " '{print $2}' | cut -d : -f 2`\" "; done; echo -e "\n"; fi

Busca informações sobre serviços com portas abertas

# netstat -nlpt | grep tcp > netstat.tmp ; cat netstat.tmp | awk -F ' ' '{print $4}' | cut -d : -f 2 | grep ^[0-9] > portas.tmp; netstat -nlpt | grep tcp | awk -F " " '{print $4}' | awk -F ":" '{ if ($1 == "") print $4 }' >> portas.tmp; cat netstat.tmp | awk -F ' ' '{print $7}' | cut -d '/' -f 2 | sed 's/:$//g' > servicos.tmp ; paste -d : servicos.tmp portas.tmp | uniq | sed 's/$/,/' | sed ':a;$!N;s/\n//;ta;' | sed 's/,$//g'; rm -f netstat.tmp portas.tmp servicos.tmp