?? mail2sms.sh
字號:
#!/bin/sh ## mail2sms a shell script# Matt Foster # matt@molnir.demon.co.uk## Mail to SMS gateway script, version 1.0# By Andy Hawkins (andy@gently.demon.co.uk)/usr/bin/cp /dev/null /tmp/header.$$ELINE=0while [ $ELINE -lt 3 ]do read LINE echo "$LINE" >> /tmp/header.$$ if [ "$LINE" = "" ] then ELINE=3 else ELINE=0 fidoneSENDER=`head -n 1 /tmp/header.$$ | awk '{print $2}'`TARGET=`grep ^Subject: /tmp/header.$$ | awk '{print $2}'`ELINE=0while [ $ELINE -lt 2 ]do read LINE echo "$LINE" >> /tmp/body.$$ if [ "$LINE" = "" ] then let ELINE=ELINE+1 else ELINE=0 fidoneRETRY=5SENT=0while [ $RETRY -gt 1 ] && [ $SENT -eq 0 ]do MSG=`cat /tmp/body.$$` /usr/bin/sms_client $TARGET "$MSG" >> /tmp/sms.log case $? in 0) /bin/mailx -s "SMS success to $TARGET" $SENDER < /dev/null SENT=1;; 1) echo "Message too long" | \ /bin/mailx -s "SMS failure to $TARGET" $SENDER SENT=1;; 3) echo "Invalid Service Name" | \ /bin/mailx -s "SMS failure to $TARGET" $SENDER SENT=1;; 4) echo "Unknown number / name $TARGET" | \ /bin/mailx -s "SMS failure to $TARGET" $SENDER SENT=1;; *) sleep 10 let RETRY=RETRY-1;; esacdoneif [ $SENT -eq 0 ]then echo "Unable to send message after 5 attemps, please try later" | \ /bin/mailx -s "SMS failure to $TARGET" $SENDERexitfirm /tmp/header.$$rm /tmp/body.$$
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -