On 12/11/2012 12:33:15 PM, Bill Kenworthy wrote:
For years I have been using ifconfig and some simple shell magic to
extract the ip address from the adsl ppp session when it changes.  The
latest update has changed the output format of ifconfig breaking things
so if ifconfig cant be relied on, what's normally used to extract an
interfaces IP address?  I can easily rewrite the shell magic, but its
worth asking if there is some command better suited.


If you're a Python fan there is a nice tool to replace 'awk' and similar tools:
svn checkout http://pyp.googlecode.com/svn/trunk/ pyp

I've patched this to include a 'balanced' (parenthesis, brackets,..)

With the original version I use

ifconfig wlan0 | /usr/local/bin/pyp "pp.after('wlan0',2)|p[1]|p.re(r'(?<=inet )\d+\.\d+\.\d+\.\d+')"

If someone is interested in my patch I'm happy to share it,
Helmut.


Reply via email to