<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Tech-Recipes - Latest Comments in Find out which process is holding which socket open | UNIX | Tech-Recipes</title><link>http://tech-recipes.disqus.com/</link><description>Cookbook of Tech Tutorials</description><language>en</language><lastBuildDate>Tue, 17 Aug 2004 16:02:54 -0000</lastBuildDate><item><title>Re: Find out which process is holding which socket open | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/227/find-out-which-process-is-holding-which-socket-open/#comment-2767166</link><description>Just use /usr/proc/bin/pfiles &amp;lt;pid&amp;gt;   bit of a pain to do it in reverse (i.e. speicfy pid to get the port) but a simple script can rip thru it for you....&lt;br&gt;&lt;br&gt;echo "which port?&amp;gt; "&lt;br&gt;read port&lt;br&gt;&lt;br&gt;for pid in `ps -ef -o pid | tail +2`&lt;br&gt;do&lt;br&gt;        foundport=`/usr/proc/bin/pfiles $pid 2&amp;gt;&amp;amp;1 | grep "sockname:" | grep "por&lt;br&gt;t: $port$"`&lt;br&gt;        if [ "$foundport" != "" ]&lt;br&gt;        then&lt;br&gt;                echo "proc: $pid, $foundport"&lt;br&gt;        fi&lt;br&gt;done</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Guest</dc:creator><pubDate>Tue, 17 Aug 2004 16:02:54 -0000</pubDate></item><item><title>Re: Find out which process is holding which socket open | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/227/find-out-which-process-is-holding-which-socket-open/#comment-2767165</link><description>netstat -anp works on linux, but not Solaris :-(</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Tue, 15 Jun 2004 05:35:05 -0000</pubDate></item><item><title>Re: Find out which process is holding which socket open | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/227/find-out-which-process-is-holding-which-socket-open/#comment-2767164</link><description>Actually, you can skip a whole step there... if you add the '-p' argument to netstat, it includes the PID of the process in question!&lt;br&gt;&lt;br&gt;So instead of netstat -an, try netstat -anp.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Wed, 07 Jan 2004 07:41:02 -0000</pubDate></item></channel></rss>