天天看點

可以發郵件,播放音樂,發短信的shell腳本

因公司要求,在網站挂了之後,需要播放聲音,讓大家能立刻知道,假如不在公司可以發郵件給大家,假如相關人員不能上網,可以發短信給大家,達到及時通知的目的。

#!/bin/bash

#website test scripts

while true;do

        for cycle_temp in `cat /opt/autotest/websit_url_links`

        do

                        temp=1

                        i=1

                        character_sign_1=22

                        character_sign_2=11

                                while [ ${i} -lt $character_sign_1 ]

                                do

                                        if lynx -dump `echo ${cycle_temp}` -accept_all_cookies|grep "true"

                                        then

                                                                let "temp=$temp+0"

                                        else

                                                                let "temp=$temp+1"

                                        fi

                                        let "i=${i}+1"

                                        echo ${i}

                                        echo ${temp}

                                        sleep 5s

                                done

                if [ ${temp} -gt $character_sign_2 ]

                then

                        echo "${cycle_temp} has been down"

                        echo "${cycle_temp} has been offline,please attend it now!">/opt/autotest/test.txt

                        mail -s "website down mail" [email][email protected][/email]</opt/autotest/test.txt

                        mplayer /opt/autotest/love.mp3

                        for read_phone in `cat /opt/autotest/PS_MobilePone.txt`

                        do

                        echo "sms `echo $read_phone` '`echo $cycle_temp` has been offline,please attend it now!'" >> /opt/autotest/sendmessage.txt

                        done

                        echo "exit" >>/opt/autotest/sendmessage.txt

                        /opt/fetion/install/fetion -u 13521186114 -p 111111 -b /opt/autotest/sendmessage.txt

                fi

                rm -rf /opt/autotest/sendmessage.txt

        done

        sleep 10m

done 

本文轉自guoli0813 51CTO部落格,原文連結:http://blog.51cto.com/guoli0813/127681,如需轉載請自行聯系原作者