title: Blog post: Musik Script History date: 2013-05-17 comments: true --- Ja, ich gebe zu, daß mein [Shell Skript][s] wirklich sehr hässlich war. Jetzt ist es zwar immer noch hässlich, aber nicht ganz so sehr. Und es merkt sich die letzten 10 gespielten Songs. Fuck yeah :D Der Output ist nach wie vor [hier zu sehen][musik]...
#!/bin/sh
lasttrack=`cat /Users/thomas/.lasttrack`
host=`hostname`
datum=`date`
if [ "$1" != "$lasttrack" ]; then
if [ "$1" != "" ]; then
echo "<html><head><meta charset=\"utf-8\" /><title>xythobuz listened to...</title></head><body><pre>" > /Users/thomas/.tmpfile
echo "Last song played on <b>${host}</b>'s iTunes:" >> /Users/thomas/.tmpfile
echo >> /Users/thomas/.tmpfile
echo " <b>$1</b>" >> /Users/thomas/.tmpfile
echo "by" >> /Users/thomas/.tmpfile
echo " <b>$2</b>" >> /Users/thomas/.tmpfile
echo "on the Album" >> /Users/thomas/.tmpfile
echo " <b>$3</b>" >> /Users/thomas/.tmpfile
echo "at" >> /Users/thomas/.tmpfile
echo " <i>${datum}</i>" >> /Users/thomas/.tmpfile
echo >> /Users/thomas/.tmpfile
echo "Last Songs played:" >> /Users/thomas/.tmpfile
cat /Users/thomas/.trackhistory >> /Users/thomas/.tmpfile
echo "</pre></body></html>" >> /Users/thomas/.tmpfile
scp /Users/thomas/.tmpfile zaphod:/var/www/lastmusic
echo $1 > /Users/thomas/.lasttrack
echo "<b>$1</b> by <b>$2</b> on <b>$3</b> at <i>${datum}</i>" >> /Users/thomas/.trackhistory
tail -n 10 /Users/thomas/.trackhistory | tee /Users/thomas/.trackhistory
fi
fi
[musik]: http://xythobuz.de/lastmusic
[s]: http://xythobuz.de/2013_05_09_itunes.html