Click to See Complete Forum and Search --> : Linux Command Help (this is kind of sneaky)
xxarmoxx
Apr 10th, 2009, 09:18 PM
Can someone help me get this command work better:
wget -q -O- http://showipaddress.com | grep '<h1 id="ip">'
I want to grab just the ip address, nothing else.
Thanks
visualAd
Apr 11th, 2009, 07:48 AM
Using xgrep, you can pull out the IP address with xpath.
wget -q --user-agent="" -O - http://ip-address.domaintools.com/myip.xml | # no user agent
xgrep -x "/dnstools/ip_address/text()" | # pull out <ip_address>
grep --invert-match -i "<" # remove comment lines with inverted regex
I've used ip-address.com because it gives you the option of an XML output of the IP info. The above code is only for purposes of an example and you must seek permission of the site owner or consult their fair usage policy if you intend to use the as part of an automated process for commercial or non commercial purposes.
penagate
Apr 12th, 2009, 09:25 AM
Just the IP address:
wget -q -O - http://whatismyip.org/
visualAd
Apr 12th, 2009, 09:57 AM
Just the IP address:
wget -q -O - http://whatismyip.org/
Well, I say, quite sneaky.
tr333
Apr 13th, 2009, 03:10 AM
wget -q -O- http://checkip.dyndns.com/ | tr -sc '0-9.' ' ' | sed -e 's/\s*//g'
1. Grab the output of http://checkip.dyndns.com/
2. Substitute all non-IP address characters into a single space with 'tr'. This will leave a single space on each side of the IP address.
3. Remove the spaces from the output with 'sed'.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.