gabriel rosenkoetter on 4 Mar 2004 16:03:02 -0000 |
On Thu, Mar 04, 2004 at 10:40:13AM -0500, Martin DiViaio wrote: > Anyone know of an easy way to find an open, non-priviledged TCP port in > bash? > > I could troll through the output from netstat and then pick a port that > isn't listed, but I'm hoping there is an easier solution. I don't think there is, since bash doesn't (or, at least, I sure HOPE it doesn't) have any networking code internal to it. netstat or lsof would be your best bets. Why do you want to do this, though? Binding to "0" gets you an unused socket which you then own, meaning there's no chance for a race condition between when you get the number and start using the socket. What problem are you trying to solve? On Thu, Mar 04, 2004 at 10:56:20AM -0500, Paul wrote: > You seem to be referring to a command-line utility. Try nmap. What possible relevance could that suggestion have? Martin's asking how to find an unused, unprivileged source port on his local system. nmap does that (every time it makes outgoing connections), but not in a way it exposes to the user. -- gabriel rosenkoetter gr@eclipsed.net Attachment:
pgprINDud3hrj.pgp
|
|