1 |
On 12/11/2012 12:33:15 PM, Bill Kenworthy wrote: |
2 |
> For years I have been using ifconfig and some simple shell magic to |
3 |
> extract the ip address from the adsl ppp session when it changes. The |
4 |
> latest update has changed the output format of ifconfig breaking |
5 |
> things |
6 |
> so if ifconfig cant be relied on, what's normally used to extract an |
7 |
> interfaces IP address? I can easily rewrite the shell magic, but its |
8 |
> worth asking if there is some command better suited. |
9 |
> |
10 |
|
11 |
If you're a Python fan there is a nice tool to replace 'awk' and |
12 |
similar tools: |
13 |
svn checkout http://pyp.googlecode.com/svn/trunk/ pyp |
14 |
|
15 |
I've patched this to include a 'balanced' (parenthesis, brackets,..) |
16 |
|
17 |
With the original version I use |
18 |
|
19 |
ifconfig wlan0 | /usr/local/bin/pyp |
20 |
"pp.after('wlan0',2)|p[1]|p.re(r'(?<=inet )\d+\.\d+\.\d+\.\d+')" |
21 |
|
22 |
If someone is interested in my patch I'm happy to share it, |
23 |
Helmut. |