shell learn 1

来源:互联网 发布:骑马与砍杀美女数据 编辑:程序博客网 时间:2024/05/16 10:17

#!/bin/bash
#chkconfig:2345 99 01
#description:wlan_ups

# Source function library.
. /etc/rc.d/init.d/functions

[ -x /wlan/power_protection/check_com ] ||  exit 0
[ -x /wlan/power_protection/tty_conf_check ] || exit 0

RETVAL=0


exec="/wlan/power_protection_start_script"
prog=$(basename $exec)


start(){
        #Check if it is already running
        if [ ! -f /var/lock/subsys/wlan_ups ];then
                echo -n "Starting wlan_ups daemon service "
                daemon $prog 
                RETVAL=$?
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/wlan_ups
                echo
        fi
        return $RETVAL
}

stop(){
        echo -n "Stopping wlan_ups daemon service: "
        killproc $prog
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /va/lock/subsys/wlan_ups
}
restart(){
        stop
        start
}

case $1 in
start)
        start
        ;;
stop)
        stop
        ;;
restart)
        stop
        start
        ;;
*)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
        ;;
esac
exit $RETVAL
(END)

 

 

2.  发邮件

#!/bin/sh
ping -c 3 pop.gmail.com
if  [ $? -eq 0 ]; then
  mail -v -s "my second mail" txwcan999@gmail.com < /project/tan/mail.txt
fi

 

3.  可以发邮件,播放音乐,发短信的shell脚本

文章出处 : http://guoli0813.blog.51cto.com/623863/127681

 

 

 

原创粉丝点击