Lynx and Geektool, temperature has extra words...

Discussion in 'Mac Basics and Help' started by Jynxxander, Feb 26, 2009.

  1. Jynxxander macrumors member

    Joined:
    Sep 7, 2008
    #1
    I'm using Lynx to display the temperature in Geektool, but for some reason "inthe" is added to it.

    I'm using the code:
    Code:
    lynx -dump http://printer.wunderground.com/cgi-bin/findweather/getForecast?query=44221|awk '/Temperature /{printf $2, ": "; for (i=3; i<=3; i++) printf $i " " }'
    
    and this one causes the same thing,

    Code:
    lynx -dump http://printer.wunderground.com/cgi-bin/findweather/getForecast?query=44221|awk '/Temp/{printf $2, ": "; for (i=3; i<=3; i++) printf $i " " }'  
    [​IMG]
     
  2. BlueRevolution macrumors 603

    BlueRevolution

    Joined:
    Jul 26, 2004
    Location:
    Montreal, QC
    #2
    My regexp abilities are rather pathetic, but here's a messy hack using grep:

    Code:
    curl -s http://printer.wunderground.com/cgi-bin/findweather/getForecast?query=44221 | grep -A 2 Temperature | grep nbsp | awk '{print substr($0, 6, length-22)}'
    Thanks for the opportunity to read up on awk, by the way. Figuring this one out gave me an excuse to familiarize myself a bit with the command.
     
  3. Jynxxander thread starter macrumors member

    Joined:
    Sep 7, 2008
    #3
    Thanks, but it's missing the degrees Fahrenheit that looks so good. Know anyway to add that?
     
  4. BlueRevolution macrumors 603

    BlueRevolution

    Joined:
    Jul 26, 2004
    Location:
    Montreal, QC
    #4
    Code:
    curl -s http://printer.wunderground.com/cgi-bin/findweather/getForecast?query=44221 | grep -A 2 Temperature | grep nbsp | awk '{print substr($0, 6, length-22) "ºF"};'
     
  5. Jynxxander thread starter macrumors member

    Joined:
    Sep 7, 2008
    #5
    No luck, it gives me something like 50.5ÅF
     
  6. BlueRevolution macrumors 603

    BlueRevolution

    Joined:
    Jul 26, 2004
    Location:
    Montreal, QC
    #6
    Code:
    lynx -dump http://printer.wunderground.com/cgi-bin/findweather/getForecast?query=44221 | grep -m 1 Temperature | awk '{print substr($0, 44, length-43)}'
    Better?
     
  7. Jynxxander thread starter macrumors member

    Joined:
    Sep 7, 2008
    #7
    Worse. :(
    Now there is nothing.
     

Share This Page