LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-19-2010, 10:37 AM   #1
jtag
Member
 
Registered: Aug 2008
Posts: 33

Rep: Reputation: 0
Locate WAN IP from command line using lynx and www.whatismyip.com


I would like to know how to locate the IP address using:
1) lynx
2) web site: http://www.whatismyip.com/tools/ip-address-lookup.asp

FYI, I am able to detect my WAN IP address with the next command:

WANIP=$(lynx -dump http://www.whatismyip.com|grep -i "Your IP Address Is"|awk '{print $5}'); echo $WANIP
 
Old 09-19-2010, 01:54 PM   #2
Peacedog
Guru
 
Registered: Sep 2003
Location: Danville, VA
Distribution: Slackware, Windows, FreeBSD, OpenBSD, Mac OS X
Posts: 5,292

Rep: Reputation: 167Reputation: 167
Hi jtag, Welcome to LQ. I just used lynx with the link you provided and it worked as expected. Just type G for go, then paste the url in and hit enter. Is this not working for you?

Good luck. ;-)
 
Old 09-19-2010, 04:00 PM   #3
jtag
Member
 
Registered: Aug 2008
Posts: 33

Original Poster
Rep: Reputation: 0
The lynx is working with "http://www.whatismyip.com/tools/ip-address-lookup.asp" but (maybe I was not clear) I would like to implement this in a bash script and to grep the location (Canada, USA ...).
The problem is that I have to enter the IP on the site and I don't know how to implement this in a script.

Last edited by jtag; 09-19-2010 at 04:03 PM.
 
Old 09-19-2010, 06:42 PM   #4
Peacedog
Guru
 
Registered: Sep 2003
Location: Danville, VA
Distribution: Slackware, Windows, FreeBSD, OpenBSD, Mac OS X
Posts: 5,292

Rep: Reputation: 167Reputation: 167
I'm afraid I won't be any help. You might start a new thread with a complete explanation of your needs.

Good luck. ;-)
 
Old 09-19-2010, 11:22 PM   #5
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
Quote:
Originally Posted by jtag View Post
The lynx is working with "http://www.whatismyip.com/tools/ip-address-lookup.asp" but (maybe I was not clear) I would like to implement this in a bash script and to grep the location (Canada, USA ...).
The problem is that I have to enter the IP on the site and I don't know how to implement this in a script.
I'm not sure if whatismyip.com has shortcut URL to determine the location of an IP. I also tried with -dump, -post_data, -cmd_log, -cmd_script (read from lynx's man page) but not success.

An alternative way, I suggest you use ip2location which has shortcut URL, therefore you can find out the location of an IP address from command line:
Code:
$ lynx -dump --accept_all_cookies http://ip2location.com/8.8.8.8 | grep -A9 "IP Address Country Region City Latitude"
                  IP Address Country Region City Latitude/
                        Longitude ZIP Code Time Zone
       8.8.8.8 [US.gif] UNITED STATES CALIFORNIA MOUNTAIN VIEW 37.3956
                      -122.076 [85]94043 -08:00 Map It

                  Net Speed         ISP           Domain
                     DSL    GOOGLE INCORPORATED GOOGLE.COM

               IDD Code Area Code       Weather Station
                  1        650    [86]USCA0746 - MOUNTAIN VIEW
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vim 'n' lynx: command line option to search for string Samsara Linux - Software 6 01-02-2013 06:36 PM
command to locate error on line # micro_xii Linux - Newbie 2 03-18-2007 07:22 PM
How can I determine my WAN IP via Command line? lucktsm Linux - Networking 6 08-31-2006 12:48 PM
cpan> locate -u Unknown shell command 'locate -u'. Type ? for help. sharad2005 Linux From Scratch 1 08-04-2006 12:40 AM
Downloading files with lynx directly via command line Dade Linux - Software 5 06-11-2005 01:43 PM


All times are GMT -5. The time now is 08:56 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration