{"id":487,"date":"2011-01-28T00:30:38","date_gmt":"2011-12-01T05:51:50","guid":{"rendered":"http:\/\/kraftek.com\/blog\/no-lsof\/"},"modified":"2011-01-28T00:30:38","modified_gmt":"2011-12-01T05:51:50","slug":"no-lsof","status":"publish","type":"post","link":"\/blog\/index.php\/no-lsof\/","title":{"rendered":"no lsof?"},"content":{"rendered":"<pre>cd \/proc\n pfiles * | egrep \"^[0-9]|sockname\" | more\n Or use PCP, found at http:\/\/www.unix.ms\/pcp\/\n #!\/usr\/bin\/ksh\n #\n # PCP (PID con Port)\n # v1.07 20\/05\/2008 sam@unix.ms\n #\n # If you have a Solaris 8, 9 or 10 box and you can't\n # install lsof, try this. It maps PIDS to ports and vice versa.\n # It also shows you which peers are connected on which port.\n # Wildcards are accepted for -p and -P options.\n #\n # The script borrows from Eric Steed's excellent \"getport.sh\" script.\n #\n #\n if [ $# -lt 1 ]\n then\n echo &gt;&amp;2 \"usage: $0 [-p PORT] [-P PID] [-a ALL ] (Wildcards OK)\"\n exit 1\n fi\n while getopts :p:P:a opt\n do\n case \"${opt}\" in\n p ) port=${OPTARG};;\n P ) pid=${OPTARG};;\n a ) all=all;;\n [?]) # unknown flag\n echo &gt;&amp;2 \"usage: $0 [-p PORT] [-P PID] [-a ALL ] (Wildcards OK) \"\n exit 1;;\n esac\n done\n shift `expr $OPTIND - 1`\n if [ $port ]\n then\n # Enter the port number, get the PID\n #\n port=${OPTARG}\n echo \"PIDtProcess Name and Port\"\n echo \"_______________________________________________________\"\n for proc in `ptree -a | grep -v ptree | awk '{print $1};'`\n do\n 263\/433\n result=`pfiles $proc 2&gt; \/dev\/null| grep \"port: $port\"`\n if [ ! -z \"$result\" ]\n then\n program=`ps -fo comm -p $proc | tail -1`\n echo \"$proct$programt$portn$result\"\n echo \"_______________________________________________________\"\n fi\n done\n elif [ $pid ]\n then\n # Enter the PID, get the port\n #\n pid=$OPTARG\n # Print out the information\n echo \"PIDtProcess Name and Port\"\n echo \"_______________________________________________________\"\n for proc in `ptree -a | grep -v ptree | grep $pid| awk '{print $1};'`\n do\n result=`pfiles $proc 2&gt; \/dev\/null| grep port:`\n if [ ! -z \"$result\" ]\n then\n program=`ps -fo comm -p $pid | tail -1`\n echo \"$proct$programn$result\"\n echo \"_______________________________________________________\"\n fi\n done\n elif [ $all ]\n then\n # Show all PIDs, Ports and Peers\n #\n echo \"PIDtProcess Name and Port\"\n echo \"_______________________________________________________\"\n for pid in `ptree -a | grep -v ptree |sort -n | awk '{print $1};'`\n do\n out=`pfiles $pid 2&gt;\/dev\/null| grep \"port:\"`\n if [ ! -z \"$out\" ]\n then\n name=`ps -fo comm -p $pid | tail -1`\n echo \"$pidt$namen$out\"\n echo \"_______________________________________________________\"\n fi\n done\n fi\n exit 0<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>cd \/proc pfiles * | egrep &#8220;^[0-9]|sockname&#8221; | more Or use PCP, found at http:\/\/www.unix.ms\/pcp\/ #!\/usr\/bin\/ksh # # PCP (PID con Port) # v1.07 20\/05\/2008 sam@unix.ms # # If you have a Solaris 8, 9 or 10 box and you can&#8217;t # install lsof, try this. It maps PIDS to ports and vice versa. # [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-487","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=487"}],"version-history":[{"count":0,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/487\/revisions"}],"wp:attachment":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=487"},{"taxonomy":"post_tag","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}