[Tutor] Detecting my own IP address?

2005-06-05 Thread Simon Gerber
G'day, I'm currently blundering through a script that will let me configure and then connect to PPTP VPNs from a Linux box. Just a text-based front-end to pptp-client, really. Adding in new VPN configurations was simple. Connecting is a little harder. From the command-line I would normally

Re: [Tutor] Detecting my own IP address?

2005-06-05 Thread Terry Carroll
The Python Cookbook (1st ed) suggests this, in recipe 10.4 (Finding Your Own Name and Address): import socket myname = socket.getfqdn(socket.gethostname()) myaddr = socket.gethostbyname(myname) myaddr '192.168.1.120' ___ Tutor maillist -

Re: [Tutor] Detecting my own IP address?

2005-06-05 Thread Lee Harr
At present, the only thing I can think of is to redirect the output of 'ifconfig' into a temporary file, then read it back in and use Python and regular expressions to try and extract the IP info from that. That is basically how I do it. See here:

Re: [Tutor] Detecting my own IP address?

2005-06-05 Thread Bill Campbell
On Sun, Jun 05, 2005, Lee Harr wrote: At present, the only thing I can think of is to redirect the output of 'ifconfig' into a temporary file, then read it back in and use Python and regular expressions to try and extract the IP info from that. Why go to a temporary file when you can open a pipe?

Re: [Tutor] Detecting my own IP address?

2005-06-05 Thread Simon Gerber
Thank you for your suggestions everyone. I do wish to parse ifconfig, as I'm specifically after the address of ppp0. At this stage, I'm only writing the script for my own machine, so the downside to parsing ifconfig does not yet apply. I'm a little curious, however. When you say 'varies depending

Re: [Tutor] Detecting my own IP address?

2005-06-05 Thread Bill Campbell
On Mon, Jun 06, 2005, Simon Gerber wrote: Thank you for your suggestions everyone. I do wish to parse ifconfig, as I'm specifically after the address of ppp0. At this stage, I'm only writing the script for my own machine, so the downside to parsing ifconfig does not yet apply. I'm a little