allyourzigg
April 26th, 2007, 10:39 PM
I'm unsure whether or not this should be here or in general but I have a small script that is designed to play a song (in this case reveille) at a certain time (thanks cron) to wake me up. The problem is that it will work fine when I run the script manually for testing but when cron attempts to run it I hear no sound and do not wake up.
the only thing that appears to not be working is the sound because the volume does change and go back. The commands each work individually in cron.
#!/bin/bash
VOL="40"
SND_FILE="/root/sound/reveille.mp3"
if [ "$UID" = '0' ]
then
#Check volume and push it to variable
CUR_VOL=`amixer -c 0 | grep Mono\: | cut -d [ -f 1 | cut -c 18-19`
#Set New volume so I don't get scared out of bed
amixer -c 0 set PCM $VOL\%
#Play file
mpg321 $SND_FILE
#Set Volume back to original level
amixer -c 0 set PCM $CUR_VOL\%
exit 0
else
echo "You are not root! Please become root to run this script"
exit 67
fi
the only thing that appears to not be working is the sound because the volume does change and go back. The commands each work individually in cron.
#!/bin/bash
VOL="40"
SND_FILE="/root/sound/reveille.mp3"
if [ "$UID" = '0' ]
then
#Check volume and push it to variable
CUR_VOL=`amixer -c 0 | grep Mono\: | cut -d [ -f 1 | cut -c 18-19`
#Set New volume so I don't get scared out of bed
amixer -c 0 set PCM $VOL\%
#Play file
mpg321 $SND_FILE
#Set Volume back to original level
amixer -c 0 set PCM $CUR_VOL\%
exit 0
else
echo "You are not root! Please become root to run this script"
exit 67
fi