On Tue, Jun 19, 2007 at 08:39:24AM -0700, Skip Tavakkolian wrote:
cpu% netstat | grep https
tcp  25   none       Listen       https      0          ::
cpu% grep '/net/tcp/25' /proc/*/fd
/proc/8429/fd: 13 rw I    0 (000000000002040c     0 00)     0        2 
/net/tcp/25/listen
cpu% ps -eaf|grep 8429
none           8429    0:00   0:00     1404K Pread    httpd ?
fst           17202    0:00   0:00      156K Pread    grep 8429
cpu%

I don't think that helps. As he said, you usually just see the open clone file for apps which are listening. The open on the listen file doesn't return until there's an incoming connection, so it's only ever visible for programs with active incoming connections. There might be a simpler (and faster) way, but something like this will probably get you what you want:

#!/bin/rc

port = $1

cd /net/tcp
c = `{grep -l !$port'$' */local | sed 's,/.*,,'}
l = `{grep -l '^Listen' $c^/status | sed 's,/.*,,'}
q = `{du -q $l^/ctl | awk '{print $1}'}

grep -l -e^$q /proc/*/fd | awk -F/ '{print $3}'

--
Kris Maglione

People to whom you are attracted invariably thing you
remind them of someone else.

Attachment: pgpKWK3iZUDDR.pgp
Description: PGP signature

Reply via email to