* [gentoo-user] ifconfig and ppp0 address
@ 2012-12-11 11:33 Bill Kenworthy
2012-12-11 11:55 ` Alan McKinnon
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Bill Kenworthy @ 2012-12-11 11:33 UTC (permalink / raw
To: gentoo-user
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.
BillK
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] ifconfig and ppp0 address
2012-12-11 11:33 [gentoo-user] ifconfig and ppp0 address Bill Kenworthy
@ 2012-12-11 11:55 ` Alan McKinnon
2012-12-11 12:08 ` Helmut Jarausch
2012-12-11 15:28 ` David W Noon
2 siblings, 0 replies; 7+ messages in thread
From: Alan McKinnon @ 2012-12-11 11:55 UTC (permalink / raw
To: gentoo-user
On Tue, 11 Dec 2012 19:33:15 +0800
Bill Kenworthy <billk@iinet.net.au> 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.
>
> BillK
>
>
>
ip tends to be a little more consistent and a little more
script-friendly than ifconfig:
ip -o addr show
-o prints output on one line, making your subsequent grep, sed and
awking easier
--
Alan McKinnon
alan.mckinnon@gmail.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] ifconfig and ppp0 address
2012-12-11 11:33 [gentoo-user] ifconfig and ppp0 address Bill Kenworthy
2012-12-11 11:55 ` Alan McKinnon
@ 2012-12-11 12:08 ` Helmut Jarausch
2012-12-11 15:28 ` David W Noon
2 siblings, 0 replies; 7+ messages in thread
From: Helmut Jarausch @ 2012-12-11 12:08 UTC (permalink / raw
To: gentoo-user
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] ifconfig and ppp0 address
2012-12-11 11:33 [gentoo-user] ifconfig and ppp0 address Bill Kenworthy
2012-12-11 11:55 ` Alan McKinnon
2012-12-11 12:08 ` Helmut Jarausch
@ 2012-12-11 15:28 ` David W Noon
2012-12-11 17:43 ` Kevin Chadwick
2 siblings, 1 reply; 7+ messages in thread
From: David W Noon @ 2012-12-11 15:28 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]
On Tue, 11 Dec 2012 19:33:15 +0800, Bill Kenworthy wrote about
"[gentoo-user] ifconfig and ppp0 address":
>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.
I wrote a command in C++ that interrogates the TCP/IP stack directly to
obtain the IP address of any given interface. I wrote it some years
ago, so it's only IPv4 at the moment; it will take a day or two to add
IPv6 support.
I can send you the source code if you want. Likewise to any other
interested reader -- or I can post it here as a mail attachment, since
it is quite tiny.
--
Regards,
Dave [RLU #314465]
======================================================================
dwnoon@ntlworld.com (David W Noon)
======================================================================
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] ifconfig and ppp0 address
2012-12-11 15:28 ` David W Noon
@ 2012-12-11 17:43 ` Kevin Chadwick
2012-12-13 15:33 ` Trevor D. Manning
0 siblings, 1 reply; 7+ messages in thread
From: Kevin Chadwick @ 2012-12-11 17:43 UTC (permalink / raw
To: gentoo-user
> I can send you the source code if you want. Likewise to any other
> interested reader
Send to me please, Thanks
--
_______________________________________________________________________
'Write programs that do one thing and do it well. Write programs to work
together. Write programs to handle text streams, because that is a
universal interface'
(Doug McIlroy)
_______________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] ifconfig and ppp0 address
2012-12-11 17:43 ` Kevin Chadwick
@ 2012-12-13 15:33 ` Trevor D. Manning
2012-12-14 0:06 ` David W Noon
0 siblings, 1 reply; 7+ messages in thread
From: Trevor D. Manning @ 2012-12-13 15:33 UTC (permalink / raw
To: gentoo-user
I'm interested also, thanks good sir
* Kevin Chadwick (ma1l1ists@yahoo.co.uk) wrote:
> > I can send you the source code if you want. Likewise to any other
> > interested reader
>
> Send to me please, Thanks
>
--
Trevor D. Manning
BOFH Excuse #98:
The vendor put the bug there.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] ifconfig and ppp0 address
2012-12-13 15:33 ` Trevor D. Manning
@ 2012-12-14 0:06 ` David W Noon
0 siblings, 0 replies; 7+ messages in thread
From: David W Noon @ 2012-12-14 0:06 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1.1: Type: text/plain, Size: 749 bytes --]
On Fri, 14 Dec 2012 02:33:56 +1100, Trevor D. Manning wrote about Re:
[gentoo-user] ifconfig and ppp0 address:
> I'm interested also, thanks good sir
>
> * Kevin Chadwick (ma1l1ists@yahoo.co.uk) wrote:
> > > I can send you the source code if you want. Likewise to any other
> > > interested reader
> >
> > Send to me please, Thanks
> >
Hi Trevor,
Attached is a tarball of the source code. Note that you need to check
the Makefile, particularly to ensure the CHOST variable is appropriate
to your system.
--
Regards,
Dave [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
dwnoon@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
[-- Attachment #1.2: get_ip_addr.tgz --]
[-- Type: application/x-compressed-tar, Size: 3312 bytes --]
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-12-14 0:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-11 11:33 [gentoo-user] ifconfig and ppp0 address Bill Kenworthy
2012-12-11 11:55 ` Alan McKinnon
2012-12-11 12:08 ` Helmut Jarausch
2012-12-11 15:28 ` David W Noon
2012-12-11 17:43 ` Kevin Chadwick
2012-12-13 15:33 ` Trevor D. Manning
2012-12-14 0:06 ` David W Noon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox