From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 19 Jun 2007 12:13:47 -0400 From: Kris Maglione To: 9fans@cse.psu.edu Subject: Re: [9fans] equivalent of fstat | grep $portnumber ? Message-ID: <20070619161347.GA67517@kris.home> References: <20070619152735.GB6960@pestilenz.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+QahgC5+KEYLbs62" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.15 (2007-04-06) Topicbox-Message-UUID: 81b9f742-ead2-11e9-9d60-3106f5b1d025 --+QahgC5+KEYLbs62 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 /ne= t/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%=20 I don't think that helps. As he said, you usually just see the open=20 clone file for apps which are listening. The open on the listen file=20 doesn't return until there's an incoming connection, so it's only ever=20 visible for programs with active incoming connections. There might be a=20 simpler (and faster) way, but something like this will probably get you=20 what you want: #!/bin/rc port =3D $1 cd /net/tcp c =3D `{grep -l !$port'$' */local | sed 's,/.*,,'} l =3D `{grep -l '^Listen' $c^/status | sed 's,/.*,,'} q =3D `{du -q $l^/ctl | awk '{print $1}'} grep -l -e^$q /proc/*/fd | awk -F/ '{print $3}' --=20 Kris Maglione People to whom you are attracted invariably thing you remind them of someone else. --+QahgC5+KEYLbs62 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.3 (FreeBSD) iD8DBQFGeAC5seQZD8Aui4wRAh6GAJ9ugtoXl3EH4Hk3jhZlHP/HOmP0KQCePOcN bWrGuLadKAqSy473qnKQig0= =0x6m -----END PGP SIGNATURE----- --+QahgC5+KEYLbs62--