Network

nslookup-scan of IP-range/subnet

#!/bin/bash # nslookup-scan of IP-range # It’s possible to add more networks separated with space NETS=”192.168.0″ IPRange=”1 254″ for NET in $NETS; do for n in $(seq $IPRange); do ADDR=${NET}.${n} echo “${ADDR},`nslookup ${ADDR} | awk -F “=” ‘{ print $2 }’|sed ‘s/^[ t]*//’ | sed ‘/^$/d’ | |sed ‘s/.$//’`” done done Result 192.168.0.1,cba.infra.no 192.168.0.2,bca.infra.no 192.168.0.3,abc.infra.no […]

Read More
Linux

Hints and Tips for general shell script programming

WARNING: this will fail if the user is playing with $0 For example using a symbolic or hard link with a unexpected name. # Simplest… # PROGNAME=`type $0 | awk ‘{print $3}’` # search for executable on path PROGNAME=`basename $PROGNAME` # base name of program # Advanced… # Script name, in what directory, and in […]

Read More
Linux

List processes in a hierarchy

ps -e -o pid,args –forest List processes by % cpu usage ps -e -o pcpu,cpu,nice,state,cputime,args –sort pcpu | sed ‘/^ 0.0 /d’ List processes by mem usage ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS List info for particular process IDs ps -p 1,2

Read More