Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Status
Not open for further replies.
Some curl scripts for an RSS feed and mupromo.com

Here are two scripts I use to display an RSS News Feed from Yahoo and the current mupromo.com software.

RSS Feed:

Code:
curl --silent "http://rss.news.yahoo.com/rss/topstories" | grep -E '(title>)' | \
  sed -n '4,$p' | 
  sed -e 's/<title>//' -e 's/<\/title>//' |
  sed -e 's/<!\[CDATA\[//g' |            
  sed -e 's/\]\]>//g' |         
  sed -e 's/<[^>]*>//g' |   
  sed -e '/^[ ]*$/d' |
  head $headarg

mupromo.com:

Software:

Code:
curl --silent "http://www.mupromo.com" | grep "div class=\"head1\"" | sed -e 's/<div class=\"head1\">//' | sed -e 's/<.*//'

Description:

Code:
curl --silent "http://www.mupromo.com" | grep "div class=\"body1-content\">" | sed -e 's/<[^>]*>//g'
 
Can anyone help me with this stock quote command:

Code:
curl http://www.google.com/finance?q=mgm | sed -n '/chg/{x;1!p;g;p;n;p;};h' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | tail -3 | sed '$!N;s/\n/ /'| sed '$!N;s/\n/ /' | sed '$!N;s/\n/ /' | sed 's/^/MGM /g'

It works except I'm not getting the current price.

Any help would be greatly appreciated thanks.
 
Does anybody have the script for a horizontal calendar?

My monthly calendar changed to august days and dates but now it wraps because of not enough days along the top. Any help on the code would be appreciated.
aug.png

i had the same problem from july to august...

Code:
cal | sed -e '1d' -e '2p;2p;2p;2p;2p' | sed -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/././g') /"

All that was needed was an extra 2p and then another -e '$!N;s/\n/
 
i had the same problem from july to august...

Code:
cal | sed -e '1d' -e '2p;2p;2p;2p;2p' | sed -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/././g') /"

All that was needed was an extra 2p and then another -e '$!N;s/\n/
Perfect. Thanks.

Will I have to do this for each month to calculate the start day of week and date?
 
Perfect. Thanks.

Will I have to do this for each month to calculate the start day of week and date?

No wait the dates and the days don't line up. Using the courier new as the font like before. Aug 1 starts on a Thursday and it should start on a Saturday.
cal | sed -e '1d' -e '2p;2p;2p;2p;2p' | sed -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/././g') /"
Stupid me. Had the text set to right instead of centered. Duh!
 
Most of the scripts came from this thread. Still a few bugs, but it's pretty much complete.


If anyone has any suggestions or questions, feel free.

Please tell me your script for the quote in the middle!
 
Or if anyone could help me get the quote of the day simply, that would be great, this doesn't seem to be working:

Code:
curl encarta.msn.com/encnet/feeds/rssfeed.aspx?typ e=quote | grep description | sed -e 's/\(.*\)//' -e 's/.*//'
 
Or if anyone could help me get the quote of the day simply, that would be great, this doesn't seem to be working:

Code:
curl encarta.msn.com/encnet/feeds/rssfeed.aspx?typ e=quote | grep description | sed -e 's/\(.*\)//' -e 's/.*//'

with some experimenting i came up with this

Quote by itself:
Code:
curl http://encarta.msn.com/encnet/feeds/rssfeed.aspx?type=quote | grep description | sed 's/^[ \t]*//' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | cut -d - -f 1

Author by itself:
Code:
curl http://encarta.msn.com/encnet/feeds/rssfeed.aspx?type=quote | grep description | sed 's/^[ \t]*//' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed 's/.*\(-\)/-/'

If anyone can figure out how to keep the quote and author together that would be nice but this method has it's formatting advantages too.

quoteday.jpg


EDIT:
Here is the code for the quote all on one line but I can't figure out how to add a line break for the "-author's name"

Code:
curl http://encarta.msn.com/encnet/feeds/rssfeed.aspx?type=quote | grep description | sed 's/^[ \t]*//' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'
 
Here's mine:

3791882178_b3317e1393_o.jpg


I've tried having processes scripts and weather scripts, but I can never seem to get used to it so I always tend to go back to the simple scripts. I'm happy with this for now.
 
None of my financials are working today. Anyone have any idea why? I prefer using google as the source because it updates real time whereas yahoo has a 10-15min delay.

DOW:
Code:
curl http://www.google.ca/finance?q=INDEXDJX:.DJI | sed -n '/chg/{x;1!p;g;p;n;p;};h' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | tail -3 | sed '$!N;s/\n/ /'| sed '$!N;s/\n/ /' | sed '$!N;s/\n/ /' | sed 's/^/DOW /g'

S&P:
Code:
curl http://www.google.ca/finance?q=INDEXSP:.INX | sed -n '/chg/{x;1!p;g;p;n;p;};h' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed '$!N;s/\n/ /' | sed '$!N;s/\n/ /' | sed 's/^/S\&P 500 /g' | sed '$!d'

NASDAQ:
Code:
curl http://www.google.ca/finance?q=INDEXNASDAQ:.IXIC | sed -n '/chg/{x;1!p;g;p;n;p;};h' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed '$!N;s/\n/ /' | sed '$!N;s/\n/ /' | sed 's/^/NASDAQ /g' | sed '$!d'

any help would be greatly appreciated.
 
with some experimenting i came up with this

Quote by itself:
Code:
curl http://encarta.msn.com/encnet/feeds/rssfeed.aspx?type=quote | grep description | sed 's/^[ \t]*//' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | cut -d - -f 1

Author by itself:
Code:
curl http://encarta.msn.com/encnet/feeds/rssfeed.aspx?type=quote | grep description | sed 's/^[ \t]*//' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed 's/.*\(-\)/-/'

If anyone can figure out how to keep the quote and author together that would be nice but this method has it's formatting advantages too.

quoteday.jpg


EDIT:
Here is the code for the quote all on one line but I can't figure out how to add a line break for the "-author's name"

Code:
curl http://encarta.msn.com/encnet/feeds/rssfeed.aspx?type=quote | grep description | sed 's/^[ \t]*//' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'

Thanks so much, how do you figure out what code to place to show the text?
 
Geektool is very buggy. It really needs to be updated. Some things that really bother me are sometimes if I am trying to scroll down the list of all my scripts, system preferences crashes, and it doesn't automatically turn on at startup.
 
So, what exactly would be the shell command to retrieve the information displayed here:
308cmjr.jpg


Either as one command or four separate ones. (Prefer one command with line breaks if possible or no line breaks.)

That's the only command I want. I don't need to know the top info like current app using the most processor, or even the processor usage. Just RAM usage. Free, Wired, Active and Inactive.

I would only be calling it every 5-10 minutes or so just to keep processor usage down. (I only call my weather scripts every 900 seconds -- 15 minutes)

This code should put the memory info all on one line. Haven't tried to do it with line breaks yet.

Code:
top -ocpu -l1 | grep 'PhysMem' | sed 's/PhysMem:  *//'
 
I'm very green to this.:eek: This is after some tweaking....please don't be too mean. btw- Not sure if it was posted here yet but I found this Youtube video extremely helpful.
 

Attachments

  • Picture 1.png
    Picture 1.png
    335.8 KB · Views: 293
nice setup! can i get your horizontal calendar script. mine seem to all be messed up since it turned august.
cal | sed -e '1d' -e '2p;2p;2p;2p;2p' | sed -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/././g') /"
There you go. Also at post 730.
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.