Results 1 to 14 of 14
  1. #1
    Shell Script in GeekTool trouble ...
    TattooedMac's Avatar
    Member Since
    May 19, 2009
    Location
    Waiting for a mate . . .
    Posts
    8,379
    Specs:
    21" iMac 2.9Ghz 16GB RAM & 13"MBP 2.9Ghz i7 8GB RAM 10.10.3, iPhone5 & iPad Air 2 iOS 8.3, ATV3
    Shell Script in GeekTool trouble ...
    Hello all.

    Am a noob to this writing scripts and what not. I am ATM using GeekTool to make my active desktop and am not doing to bad.
    I have been finding scripts and tweaking and playing with them to suit myself and very slowly learning the code.

    My problem is the script i have for my weather is from a site on other side of the world and hasnt up to date info for where i live.

    I havnt found away to make it run with my weather site i use here in Australia.
    The URL other[s/ or most of the scripts are for www.wunderland.com and the code is

    Code:
    curl http://m.wund.com/global/stations/94975.html|sed -n '21p' | sed -e 's/<span class="nowrap"><b>//g' | sed -e 's/<\/b.*//g'
    And no i havnt had any joy with the code for the use of lynx so have to use curl.

    I am wanting a script so i can use www.eldersweather.com

    I have played with the above mentioned and for the life of me cant do it.

    When i use Elders in the script i get " <: Code used in public domain" or something to that effect.
    Can anyone point me in the right direction ?? Would be greatly appreciated.

    ANd i really hope this all makes sense BC as i said before im so NEW to this code thing..

    Thanks in advance people
    Dont forget to use the Reputation System if someone has helped you out !!!
    Arguing with a zealot is only slightly easier than tunneling through a mountain with your forehead!!!!!
    MoTM ☆☆☆

  2. #2
    Shell Script in GeekTool trouble ...
    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,821
    Specs:
    Way... way too many specs to list.
    Ok, lets break this down....

    gets that page.

    the sed -n '21p' parses out the following...

    Code:
    mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p'
      <span class="nowrap"><b>14</b>&#176;C</span>
    mikeMbp:~ mike$
    sed -e 's/<span class="nowrap"><b>//g' and sed -e 's/<\/b.*//g' are line substitution strings so the first gets us
    Code:
    mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p'|sed -e 's/<span class="nowrap"><b>//g'
      14</b>&#176;C</span>
    and the second gets us
    Code:
    mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p'|sed -e 's/<span class="nowrap"><b>//g'| sed -e 's/<\/b.*//g' 
      14
    Now, if your OTHER page is not identically laid out.. you'll have to change your sed statements to match. I have to go pick my kids up from school, I'll check when I get back and play with that one if need be.
    mike
    This machine kills fascists
    Got # ? phear the command line!

  3. #3
    Shell Script in GeekTool trouble ...
    dbnoise's Avatar
    Member Since
    Dec 21, 2008
    Posts
    314
    Another way to display weather in geektool is use yweather.pl, which is a really nice script someone wrote that uses yahoo weather.
    Here's a link if you want to check it out: yweather - Project Hosting on Google Code

  4. #4
    Shell Script in GeekTool trouble ...
    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,821
    Specs:
    Way... way too many specs to list.
    Ok, so.. I redid that whole thing piping things to files (which eliminated the transmission details)...


    Code:
    mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p' |sed -e 's/<span class="nowrap"><b>//g' |sed -e 's/<\/b.*//g' 
      14
    mikeMbp:~ mike$ cat hobartweather.tst |sed -n '21p' |sed -e 's/<span class="nowrap"><b>//g' |sed -e 's/<\/b.*//g' 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    mikeMbp:~ mike$
    so.. this should work...

    Code:
    curl http://www.eldersweather.com.au/tas/lower-derwent/hobart?fc=9329  |sed -n '448p' |sed -e 's/<td class="center bold">//g' |sed -e 's/&.*//g'
    Code:
    mikeMbp:~ mike$ cat hobartweather.tst |sed -n '448p' |sed -e 's/<td class="center bold">//g' |sed -e 's/&.*//g' 
    			14.5
    mikeMbp:~ mike$
    edit.. how did I find the line number?
    Code:
    mikeMbp:~ mike$ cat -n hobartweather.tst |grep 14.5
       448				<td class="center bold">14.5&deg;C</td>
    mike
    This machine kills fascists
    Got # ? phear the command line!

  5. #5
    Shell Script in GeekTool trouble ...
    TattooedMac's Avatar
    Member Since
    May 19, 2009
    Location
    Waiting for a mate . . .
    Posts
    8,379
    Specs:
    21" iMac 2.9Ghz 16GB RAM & 13"MBP 2.9Ghz i7 8GB RAM 10.10.3, iPhone5 & iPad Air 2 iOS 8.3, ATV3
    Quote Originally Posted by dbnoise View Post
    Another way to display weather in geektool is use yweather.pl, which is a really nice script someone wrote that uses yahoo weather.
    Here's a link if you want to check it out: yweather - Project Hosting on Google Code
    Thanks db ill check this out too

    Quote Originally Posted by Dysfunction View Post
    Ok, so.. I redid that whole thing piping things to files (which eliminated the transmission details)...


    Code:
    mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p' |sed -e 's/<span class="nowrap"><b>//g' |sed -e 's/<\/b.*//g' 
      14
    mikeMbp:~ mike$ cat hobartweather.tst |sed -n '21p' |sed -e 's/<span class="nowrap"><b>//g' |sed -e 's/<\/b.*//g' 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    mikeMbp:~ mike$
    so.. this should work...

    Code:
    curl http://www.eldersweather.com.au/tas/lower-derwent/hobart?fc=9329  |sed -n '448p' |sed -e 's/<td class="center bold">//g' |sed -e 's/&.*//g'
    Code:
    mikeMbp:~ mike$ cat hobartweather.tst |sed -n '448p' |sed -e 's/<td class="center bold">//g' |sed -e 's/&.*//g' 
    			14.5
    mikeMbp:~ mike$
    edit.. how did I find the line number?
    Code:
    mikeMbp:~ mike$ cat -n hobartweather.tst |grep 14.5
       448				<td class="center bold">14.5&deg;C</td>
    Bloody awesome mate.. Thank you muchly.

    I ran it and it works a treat and ill use the same code to get my conditions as well

    Ill do some work and learn from it ... Ill break down my old code and the new one produced by you and see the differences.
    This is a great leaning curve and hope i become more proficient at it.

    Like using my local weather site and widgets take up too much resources so AAA+++

    Cheers
    Dont forget to use the Reputation System if someone has helped you out !!!
    Arguing with a zealot is only slightly easier than tunneling through a mountain with your forehead!!!!!
    MoTM ☆☆☆

  6. #6
    Shell Script in GeekTool trouble ...
    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,821
    Specs:
    Way... way too many specs to list.
    No problem, sed and awk are both really.. really... really.. useful
    mike
    This machine kills fascists
    Got # ? phear the command line!

  7. #7
    Shell Script in GeekTool trouble ...
    TattooedMac's Avatar
    Member Since
    May 19, 2009
    Location
    Waiting for a mate . . .
    Posts
    8,379
    Specs:
    21" iMac 2.9Ghz 16GB RAM & 13"MBP 2.9Ghz i7 8GB RAM 10.10.3, iPhone5 & iPad Air 2 iOS 8.3, ATV3
    Quote Originally Posted by Dysfunction View Post
    No problem, sed and awk are both really.. really... really.. useful
    HAHA thanks but not having great deal of luck here. As stated before real nOOb to all this.
    With being a pain in the ....... You seemed to do the code for temp with such ease, and ATM my eyes are hanging out the back of my head and all the symbols are blending together lol

    Are you able to knock one up for forecast ??? If its not to much trouble.

    Im a more hands on bloke and if i was sitting beside you i would and could get a better understanding of it al ...

    with the
    Code:
     curl --silent -o /weather.png
    maybe

    If i had both working codes will be a bit easier to understand but im bushed/stuffed and lost ATM

    Appreciate it once again

    @ dbnoise if you read this that .png code for conditions didnt work, even running it under your Zip/Location and the link to THAT particular site was "Page Not Found"


    Looked at the other part of your post and i still have a bit of work to do before i can play with that... Meaning ... Being code savvy

    Thank Gents

    Dont forget to use the Reputation System if someone has helped you out !!!
    Arguing with a zealot is only slightly easier than tunneling through a mountain with your forehead!!!!!
    MoTM ☆☆☆

  8. #8
    Shell Script in GeekTool trouble ...
    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,821
    Specs:
    Way... way too many specs to list.
    yea, I'll try and get to it this evening after work and gym.

    btw, this is exactly the kind of thing I've done for a living now for over a decade (well, writing scripts etc) so after a while it becomes pretty easy, especially something like text manipulation, so it's just a matter of knowing where things are in the text
    mike
    This machine kills fascists
    Got # ? phear the command line!

  9. #9
    Shell Script in GeekTool trouble ...
    TattooedMac's Avatar
    Member Since
    May 19, 2009
    Location
    Waiting for a mate . . .
    Posts
    8,379
    Specs:
    21" iMac 2.9Ghz 16GB RAM & 13"MBP 2.9Ghz i7 8GB RAM 10.10.3, iPhone5 & iPad Air 2 iOS 8.3, ATV3
    Quote Originally Posted by Dysfunction View Post
    yea, I'll try and get to it this evening after work and gym.

    btw, this is exactly the kind of thing I've done for a living now for over a decade (well, writing scripts etc) so after a while it becomes pretty easy, especially something like text manipulation, so it's just a matter of knowing where things are in the text
    Wow thought it came easy to you, considering how quickly you replied to my posts.

    Its something im slowly getting into because i need a new career path that doesnt require to me so physical, ie: 18hrs a day truck driving or demolition, because im so broken now.

    Appreciate it and ill study your codes and see what you have done compared to others and going into town to look for learning books on code/shell script and the such.

    If you have any recommendations will take it all in heed as well..

    Cheers look forward to see what you come up with.

    Further to the request ... was looking for the conditions where i can use the image geeklet to update the image as and when the weather changes with the condition... If that makes any sense, and i didnt make sense before
    Mind you i am learning from you.. Which is great

    Cheers
    Dont forget to use the Reputation System if someone has helped you out !!!
    Arguing with a zealot is only slightly easier than tunneling through a mountain with your forehead!!!!!
    MoTM ☆☆☆

  10. #10
    Shell Script in GeekTool trouble ...
    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,821
    Specs:
    Way... way too many specs to list.
    How much of the forecasted info do you want?

    btw, with all the tables that's a mess... much easier on a simpler page.. for instance.. tomorrows forecast...

    Code:
    mikeMbp:~ mike$ curl http://www.wunderground.com/global/stations/94975.html |sed -n 1133,1144p | sed -e 's#<[^>]*>##g'
    
    		Thursday
    		Chance of Rain.
    		Partly Cloudy.
    		High:
    		66 &deg;F
    		.
    		Wind
    		South
    		17 mph
    		.
    		Chance of precipitation 30&#37;
    		(water equivalent of 0.08 in).
    mikeMbp:~ mike$
    oh and since we're printing line ranges.. it'll fail if it changes.
    mike
    This machine kills fascists
    Got # ? phear the command line!

  11. #11
    Shell Script in GeekTool trouble ...
    TattooedMac's Avatar
    Member Since
    May 19, 2009
    Location
    Waiting for a mate . . .
    Posts
    8,379
    Specs:
    21" iMac 2.9Ghz 16GB RAM & 13"MBP 2.9Ghz i7 8GB RAM 10.10.3, iPhone5 & iPad Air 2 iOS 8.3, ATV3
    Quote Originally Posted by Dysfunction View Post
    How much of the forecasted info do you want?

    btw, with all the tables that's a mess... much easier on a simpler page.. for instance.. tomorrows forecast...

    Code:
    mikeMbp:~ mike$ curl http://www.wunderground.com/global/stations/94975.html |sed -n 1133,1144p | sed -e 's#<[^>]*>##g'
    
    		Thursday
    		Chance of Rain.
    		Partly Cloudy.
    		High:
    		66 &deg;F
    		.
    		Wind
    		South
    		17 mph
    		.
    		Chance of precipitation 30&#37;
    		(water equivalent of 0.08 in).
    mikeMbp:~ mike$
    oh and since we're printing line ranges.. it'll fail if it changes.
    Nice. Really just wanting todays Temp that im using the code of yours from yesterday and i have refresh rate set at 100 sec's and in the forecast as in conditions just the ( partly cloudy ) part of it and the (partly cloudy) icon with it and changes as the conditions do. Will have the refresh rate set at 100 sec's as well.
    Dont need the precipitation and wind speeds, as its not really relevant to the info im after.
    Would be nice to have tomorrows outlook but not essential.

    Just want to keep it as simple as possible
    Make sense ?? Dont want you going out of your way !!!
    Cheers

    And is it good to play with these scripts in terminal.....
    Dont forget to use the Reputation System if someone has helped you out !!!
    Arguing with a zealot is only slightly easier than tunneling through a mountain with your forehead!!!!!
    MoTM ☆☆☆

  12. #12
    Shell Script in GeekTool trouble ...
    TattooedMac's Avatar
    Member Since
    May 19, 2009
    Location
    Waiting for a mate . . .
    Posts
    8,379
    Specs:
    21" iMac 2.9Ghz 16GB RAM & 13"MBP 2.9Ghz i7 8GB RAM 10.10.3, iPhone5 & iPad Air 2 iOS 8.3, ATV3
    Well pretty happy with myself as i have come up with this

    Code:
    TZ=Australia/GMT-11 date +"Sydney: &#37;H%M Hrs - %D"
    TZ=England/GMT date +"London: date %H%M Hrs - %D"
    TZ=NewYork/GMT5 date +"New York: %H%M Hrs - %D"
    TZ=LosAngeles/GMT8 date  +"Los Angeles: %H%M Hrs - %D"
    Showing Time zones from around the world

    And through a lot of looking around i have come up with this for the temp and conditions

    Code:
    curl --silent "http://xml.weather.yahoo.com/forecastrss?p=ASXX0057&u=c" | grep -E '(Current Conditions:|C<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//'
    I get Partly Cloudy, 21c

    Using Yahoo weather. The Elders one seemed to go beserk yesterday.

    Am happy with it all ATM but cant work out how to get rid of the comma in the weather script ...

    Thanks for you help though mate

    Cheers
    Screenshot

    Dont forget to use the Reputation System if someone has helped you out !!!
    Arguing with a zealot is only slightly easier than tunneling through a mountain with your forehead!!!!!
    MoTM ☆☆☆

  13. #13
    Shell Script in GeekTool trouble ...
    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,821
    Specs:
    Way... way too many specs to list.
    try adding | tr -d ,
    to the end...
    like such.
    Code:
    curl --silent "http://xml.weather.yahoo.com/forecastrss?p=ASXX0057&u=c" | grep -E '(Current Conditions:|C<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//'| tr -d ,
    mike
    This machine kills fascists
    Got # ? phear the command line!

  14. #14
    Shell Script in GeekTool trouble ...
    TattooedMac's Avatar
    Member Since
    May 19, 2009
    Location
    Waiting for a mate . . .
    Posts
    8,379
    Specs:
    21" iMac 2.9Ghz 16GB RAM & 13"MBP 2.9Ghz i7 8GB RAM 10.10.3, iPhone5 & iPad Air 2 iOS 8.3, ATV3
    Thumbs up Nice one !!!!
    Double thumbs up mate

    Cheers
    Dont forget to use the Reputation System if someone has helped you out !!!
    Arguing with a zealot is only slightly easier than tunneling through a mountain with your forehead!!!!!
    MoTM ☆☆☆

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. FTP Shell Script Q.
    By edwardlscott in forum OS X - Operating System
    Replies: 8
    Last Post: 03-06-2013, 01:37 AM
  2. Shell script help
    By Hyper in forum OS X - Development and Darwin
    Replies: 12
    Last Post: 05-22-2011, 11:36 AM
  3. Terminal -- shell script -- script will only read two lines of a file
    By Straitsfan in forum OS X - Apps and Games
    Replies: 0
    Last Post: 01-30-2011, 09:04 PM
  4. Geektool script forces mail to stay open
    By jmullenberg in forum OS X - Apps and Games
    Replies: 1
    Last Post: 09-27-2009, 10:01 AM
  5. Shell Script on Desktop
    By starrin in forum OS X - Operating System
    Replies: 2
    Last Post: 07-28-2004, 11:25 AM

Posting Permissions

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