checking if a streaming server is up using bash?
I use Ubuntu and am trying to write a script that makes the following:
-test if an audio stream works
-if not, send an email.

I have tried the following code (running as a cron job every 10 minutes), which 'works' if I supply the wrong pw e.g.(it sends an email then), but does nothing if the actual server is down (tested by killing the server). any ideas on how to fix the script?
Thanks in advance!


    #!/bin/bash
    #servertest.sh

 
    username=user1
    password=xyz
    

    url="http://wwww.streamingaudioserver.com -passwd $password -user $username"
 
    mplayer $url &
    sleep 5
    
    test=$(pgrep -c mplayer)
    
    if [ $test = 0 ]; then
        #server is down!
        $mailfile="downmail.txt"
        /usr/sbin/ssmtp test@maildomain.com < "/home/test/$mailfile"  
    fi
    
    killall mplayer
    sleep 5
    
    exit


checking if a streaming server is up using bash?
===

I use Ubuntu and am trying to write a script that makes the following:
-test if an audio stream works
-if not, send an email.

I have tried the following code (running as a cron job every 10 minutes), which 'works' if I supply the wrong pw e.g.(it sends an email then), but does nothing if the actual server is down (tested by killing the server). any ideas on how to fix the script?
Thanks in advance!


    #!/bin/bash
    #servertest.sh

 
    username=user1
    password=xyz
    

    url="http://wwww.streamingaudioserver.com -passwd $password -user $username"
 
    mplayer $url &
    sleep 5
    
    test=$(pgrep -c mplayer)
    
    if [ $test = 0 ]; then
        #server is down!
        $mailfile="downmail.txt"
        /usr/sbin/ssmtp test@maildomain.com < "/home/test/$mailfile"  
    fi
    
    killall mplayer
    sleep 5
    
    exit

