Results 1 to 5 of 5

Thread: Linux Command Help (this is kind of sneaky)

  1. #1

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    Linux Command Help (this is kind of sneaky)

    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

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Linux Command Help (this is kind of sneaky)

    Using xgrep, you can pull out the IP address with xpath.
    Code:
     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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Linux Command Help (this is kind of sneaky)

    Just the IP address:

    wget -q -O - http://whatismyip.org/

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Linux Command Help (this is kind of sneaky)

    Quote Originally Posted by penagate View Post
    Just the IP address:

    wget -q -O - http://whatismyip.org/
    Well, I say, quite sneaky.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: Linux Command Help (this is kind of sneaky)

    Code:
    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'.
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width