determining an assigned IP address
Jonathan Epstein
Jonathan_Epstein at nih.gov
Mon Jun 26 10:10:17 EDT 2000
The following Perl code works:
use Sys::Hostname;
use Socket;
$ip=gethostbyname(hostname());
$theip=inet_ntoa($ip);
It should be relatively straightforward to convert this to Python.
- Jonathan
Bill Tolbert wrote:
>
> I've just set up Linux with my cable modem and I'd like to use Python to
> help me launch remote X apps. I need to know the ip address assigned by
> my isp, but so far I'm striking out. gethostbyname_ex in the socket
> module returns the address I supplied when I thought it was static.
> Right now the only way I know to get the right address is to log into
> another machine and use who.
>
> All help is appreciated!
>
> Bill
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
More information about the Python-list
mailing list