Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] my first bash scripts



Hi everyone,

I was tired of always downloading these news programs that I like, then waiting, then running them, so I decided to try my hand at elementary bash scripting to automate the process. These are my first bash scripts so they are pretty simple. This one gets the latest Democracy Now and Flashpoints (two news programs I like):

#!/bin/bash
x=`date -d '-1 day' +%a`
y=`date +%Y`
z=`date -d '-1 day' +%m%d`
/usr/bin/wget -P/home/scott/Mp3s/News/Democracy_Now/ http://www.archive.org/download/dn${y}-${z}_vid/dn${y}-${z}_256kb.mp4
/usr/bin/wget -P/home/scott/Mp3s/News/Flashpoints http://aud1.kpfa.org/data/${y}${z}-${x}1700.mp3

Maybe somebody will find this script useful to get stuff from the net.

Because of the international date line you'll note it gets the date from the previous day. Being here in Japan I run it as a cron job Tue-Sat, but you could change it to Mon-Fri and remove the '-1 day' part to get the episode of the day if you're somewhere else on earth.

To play the latest Flashpoints that was downloaded I created this:

#!/bin/bash
x=`ls -lahtr /home/scott/Mp3s/News/Flashpoints/*.mp3 | awk '{print $9}' | tail -n 1`
export DISPLAY=":0.0"
/usr/bin/xmms ${x}

and did the same for Democracy Now videos:

#!/bin/bash
x=`ls -lahtr /home/scott/Mp3s/News/Democracy_Now/*.mp4 | awk '{print $9}' | tail -n 1`
export DISPLAY=":0.0"
/usr/bin/mplayer ${x}

The scripts are pretty clunky and I'm sure that most TLUG members are way beyond this, but maybe some newbies can tweak these to get other stuff from the net etc.

Cheers,
Scott VanDusen
Tokyo



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links