January 7, 2013

one-liner to get NASA image of the day as wallpaper

A quick script to download a new image from NASA everyday.
Not having looked around, I'm pretty sure there are nicer, better solutions to this out there but since this one is free and completely trivial, I thought I'd share here.

What I did:
  1. I created a folder called NASA-IOTD in my Pictures folder
  2. I created a get-image.sh file in that folder
  3. I put the one line as shown below
  4. I added an entry in crontab so it would run once a day
The script:
curl http://www.nasa.gov/rss/image_of_the_day.rss|awk '/enclosure/ {a=$0;sub(/.*enclosure/,"",a); sub(/.*url=\"/,"",a); sub(/\".*/,"",a); print a;}'|xargs curl -O

The crontab entry:
$crontab -l
30 9 * * * /Users/arno/Pictures/NASA-IOTD/get-image.sh


1 comment:

  1. Genius and good idea to get the objective and nice easy way to trick the NASA servers. I would like to get some info and more tutorials about your tricks and working.