One of the things I love about running Linux on my computer is that I can write little scripts if I need things done my way. For example, I wrote a script to connect to the internet, check my mail, and disconnect:
#!/bin/sh
# Micah Sittig, 2003.5.5
echo "-- Script to check mail and immediately disconnect --"
# Connect if not already connected
connected=0
[ -e /var/run/ppp0.pid ] && connected=1
if [ $connected -eq 1 ]; then
echo Already connected...
else
echo -n "Connecting... "
/sbin/ifup ppp0
echo connected.
fi
# If the connect succeeded, fetch the mail
[ -e /var/run/ppp0.pid ] && /home/msittig/bin/fma
# Drop the connection
echo Closing the connection.
/sbin/ifdown ppp0
exit 0
Here's another one I wrote to fix the problem of using ogg123
to play ogg files, and mpg123
to play mp3s:
#!/bin/sh
# Micah Sittig 2003.06.21
# Script to play mixes of mp3s and oggs
# using the correct program (mpg123/ogg123)
for song in "$@"
do
format=`echo $song | awk '/mp3$/ { print "mp3" } /ogg$/ { print "ogg" }'`
if [ "$format" = mp3 ]; then
/usr/local/bin/mpg123 "$song"
elif [ "$format" = "ogg" ]; then
/usr/bin/ogg123 "$song"
else
echo "play: $song: Unknown format."
fi
sleep 1
done
exit 0