terminanting bash script from background job
Was having problems getting to play mp3 off the web right so thought to make a shell program do that........ here's part of it
Code:
function download ()
{
WGETLOG="playmp3.wget-log"
MEDIAFILE=~/Download/`echo $URI | sed 's:^.*/:: ; s:[^a-zA-Z0-9\.]+:-:g'`
#run wget in background
( wget -O $MEDIAFILE -o $WGETLOG $URI
if [ $? ] ; then echo "ERROR: wget ... $URI" ; exit 1; fi ) &
}
#.................................
case $1 in
*m3u)
URI=`cat $1`
download
#wait for something to be buffered
sleep 20
#convert to wav whatever is downloaded so far & play
play
;;
so my problem here is if wget doesn't connect how to stop it from try to play the file.... as this doesn't work as written