Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] get free local port for script?



Hi,

I'd like to programmatically access a remote service over an ssh tunnel.
I need a free local port to use, and I'm wondering the best way to get
one. I can think of kludgy things like grepping thru the output of
netstat to see if some port is in use, but it seems like there should
be a cleaner way. Ideally, something like

ssh -L `getfreeport`:remotehost:remoteport......

where "getfreeport" would be my ideal function. My reference books and
google don't yield anything interesting. Ideas?

Thanks,
Ed


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links