linux - get process name, pid and port mapping from netstat command in SunOS -


i trying mapping of port number application running/using port in sunos

$netstat -tlnp netstat: illegal option -- t 

it seems -t option illegal in sunos.

how can mapping?

i got script somewhere. log solaris system. open vi editor. go insert mode. copy , paste script. close file. give execute permission. run script -p or -p swithc. give output pid, process name , port.

pcp script enables administrators see open tcp ports in use on solaris system. maps ports pids , vice versa. accepts wildcards , show @ glance open ports , corresponding pids. nice script gives fine out put. try it.

example: #pcp -p port_number or #pcp -p process_id

#!/usr/bin/ksh # # wildcards accepted -p , -p options. # # help, appreciated. i=0 while getopts :p:p:a opt ;    case "${opt}" in    p ) port="${optarg}";i=3;;    p ) pid="${optarg}";i=3;;    ) all=all;i=2;;    esac done if [ $optind != $i ];    echo >&2 "usage: $0 [-p port] [-p pid] [-a] (wildcards ok) "    exit 1 fi shift `expr $optind - 1` if [ "$port" ];    # enter port number, pid    #    port=${optarg}    echo "pid\tprocess name , port"    echo "_________________________________________________________"    proc in `ptree -a | awk '/ptree/ {next} {print $1};'` ;       result=`pfiles $proc 2> /dev/null| egrep "port: $port$"`       if [ ! -z "$result" ];then          program=`ps -fo comm= -p $proc`          echo "$proc\t$program\t$port\n$result"          echo "_________________________________________________________"       fi    done elif [ "$pid" ];    # enter pid, port    #    pid=$optarg    # print out information    echo "pid\tprocess name , port"    echo "_________________________________________________________"    proc in `ptree -a | awk '/ptree/ {next} $1 ~ /^'"$pid"'$/ {print $1};'`;       result=`pfiles $proc 2> /dev/null| egrep port:`       if [ ! -z "$result" ];then          program=`ps -fo comm= -p $proc`          echo "$proc\t$program\n$result"          echo "_________________________________________________________"       fi    done elif [ $all ];    # show pids, ports , peers    #    echo "pid\tprocess name , port"    echo "_________________________________________________________"    proc in `ptree -a | sort -n | awk '/ptree/ {next} {print $1};'` ;       out=`pfiles $proc 2>/dev/null| egrep "port:"`       if [ ! -z "$out" ];then          name=`ps -fo comm= -p $proc`          echo "$proc\t$name\n$out"          echo "_________________________________________________________"       fi    done fi exit 0 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -