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
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 -
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:
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?
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
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