| Author |
Message |
wuwei

Joined: 15 Sep 2007 Posts: 740 Location: de
|
Posted: Mon 03 Jan 2011, 09:15 Post subject:
How to get external IP address? [SOLVED] Subject description: Get IP address for use in conky |
|
This question relates to an old post
http://www.murga-linux.com/puppy/viewtopic.php?p=24927&sid=72e8730e87262e34dcdcca1aa48f6af3
I am trying to pick up my external IP address for conky and found this code on above page
| Code: | IPADR=`wget -q "http://ipid.shat.net/iponly" -O - | sed -n 3p`
echo $IPADR |
quite helpful for my non-programmer knowledge. However, the result is this:
| Quote: | | 75.112.47.248</title></head> |
As I only need the numbers upfront without < and what follows I wonder if anybody has any idea how to change the code to that end?
Very much appreciated
Last edited by wuwei on Mon 03 Jan 2011, 11:09; edited 1 time in total
|
|
Back to top
|
|
 |
rcrsn51

Joined: 05 Sep 2006 Posts: 7834 Location: Stratford, Ontario
|
Posted: Mon 03 Jan 2011, 10:22 Post subject:
|
|
| Code: | | IPADR=`wget -q "http://ipid.shat.net/iponly" -O - | sed -n 3p | cut -f 1 -d "<"` |
|
|
Back to top
|
|
 |
wuwei

Joined: 15 Sep 2007 Posts: 740 Location: de
|
Posted: Mon 03 Jan 2011, 11:07 Post subject:
thanks |
|
Wow
this was fast rcrsn51, and all across the Atlantic.
Best of all....it works like a charm.
Thanks a million.
PS: OS in question is Wary 5.0. This code gives me the external IP. Funny is that Conky in Lupu 519 shows the internal IP when addrs eth0 is entered at the appropriate place in conky.conf. This does not work in Wary. Beats me why, but I am happy with the aforementioned result.
Screenshot attached.
| Description |
|
| Filesize |
149.8 KB |
| Viewed |
975 Time(s) |

|
|
|
Back to top
|
|
 |
MagicZaurus
Joined: 05 Jan 2009 Posts: 88
|
Posted: Mon 03 Jan 2011, 12:19 Post subject:
Real IP |
|
| Code: | | curl whatismyip.org |
This gives me my real external IP address. The code from rcrsn51 gives in my case the IP of my ISP proxy server.
|
|
Back to top
|
|
 |
rcrsn51

Joined: 05 Sep 2006 Posts: 7834 Location: Stratford, Ontario
|
Posted: Mon 03 Jan 2011, 12:39 Post subject:
|
|
Using curl is much nicer!
| Code: | | IPADR=`curl whatismyip.org 2> /dev/null` |
|
|
Back to top
|
|
 |
wuwei

Joined: 15 Sep 2007 Posts: 740 Location: de
|
Posted: Mon 03 Jan 2011, 14:39 Post subject:
external IP address |
|
@rcrsn51
and
@MagicZaurus
Great, curl works, too.
But why is curl much nicer?
Just a shorter code or does it use less resources? Or what?
Thanks guys.
|
|
Back to top
|
|
 |
|