📄 check_sendsms.sh
字号:
#!/bin/sh## Use `test/fakesmsc' to test sendsms in smsbox.set -e#set -xtimes=10interval=0loglevel=0sendsmsport=13013global_sender=13013 username=testerpassword=foobarurl="http://localhost:$sendsmsport/cgi-bin/sendsms?from=123&to=234&\text=test&username=$username&password=$password"gw/bearerbox -v $loglevel gw/smskannel.conf > check_sendsms_bb.log 2>&1 &bbpid=$!sleep 2test/fakesmsc -i $interval -m $times '123 234 text nop' \ > check_sendsms_smsc.log 2>&1 &sleep 1gw/smsbox -v $loglevel gw/smskannel.conf > check_sendsms_sms.log 2>&1 &sleep 2# All cgivars are OKurl="http://localhost:$sendsmsport/cgi-bin/sendsms?from=123&to=234&\text=test&username=$username&password=$password"i=0while [ $i -lt $times ]do test/test_http $url >> check_sendsms.log 2>&1 i=`expr $i + 1`donesleep 5if grep 'WARNING:|ERROR:|PANIC:' check_sendsms*.log >/dev/null || [ $times -ne `grep -c 'Got message .*: <123 234 text test>' \ check_sendsms_smsc.log` ]then echo check_sendsms.sh failed with non-empty fields 1>&2 echo See check_sendsms*.log for info 1>&2 exit 1fi# Empty fields: message. This is OK, we must get a canned replyurl="http://localhost:$sendsmsport/cgi-bin/sendsms?from=123&to=234&\text=&username=$username&password=$password"test/test_http $url >> check_sendsms.log 2>&1if grep 'WARNING:|ERROR:|PANIC:' check_sendsms*.log >/dev/null || [ 1 -ne `grep -c '<123 234 text <Empty reply from service provider>' \ check_sendsms_smsc.log` ]then echo check_sendsms.sh failed with empty message 1>&2 echo See check_sendsms*.log for info 1>&2 exit 1fi#From. This is OK, too: now global-sender replaces from fieldurl="http://localhost:$sendsmsport/cgi-bin/sendsms?from=&to=234&\text=test&username=$username&password=$password"test/test_http $url >> check_sendsms.log 2>&1if grep 'WARNING:|ERROR:|PANIC:' check_sendsms*.log >/dev/null || [ 1 -ne `grep -c '<'$global_sender' 234 text test>' check_sendsms_smsc.log` ]then echo check_sendsms.sh failed with empty from field 1>&2 echo See check_sendsms*.log for info 1>&2 exit 1fi#To. Now smsbox must report an error.url="http://localhost:$sendsmsport/cgi-bin/sendsms?from=123&to=&\text=&username=$username&password=$password"test/test_http $url >> check_sendsms.log 2>&1if grep 'WARNING:|ERROR:|PANIC:' check_sendsms*.log >/dev/null || [ 1 -ne `grep -c 'got empty <to> cgi variable' check_sendsms_sms.log` ]then echo check_sendsms.sh failed with empty to field 1>&2 echo See check_sendsms*.log for info 1>&2 exit 1fi#Username. This is an authentication error.url="http://localhost:$sendsmsport/cgi-bin/sendsms?from=123&to=234&\text=&username=&password=$password"test/test_http $url >> check_sendsms.log 2>&1if grep 'WARNING:|ERROR:|PANIC:' check_sendsms*.log >/dev/null || [ 1 -ne `grep -c '<Authorization failed for sendsms>' \ check_sendsms_sms.log` ]then echo check_sendsms.sh failed username authorisation test 1>&2 echo See check_sendsms*.log for info 1>&2 exit 1fi#Password. Ditto.url="http://localhost:$sendsmsport/cgi-bin/sendsms?from=123&to=234&\text=&username=$username&password="if grep 'WARNING:|ERROR:|PANIC:' check_sendsms*.log >/dev/null || [ 1 -ne `grep -c '<Authorization failed for sendsms>' \ check_sendsms_sms.log` ]then echo check_sendsms.sh failed with password authorisation test 1>&2 echo See check_sendsms*.log for info 1>&2 exit 1fikill -INT $bbpidwait# Do we panic when going down ?if grep 'WARNING:|ERROR:|PANIC:' check_sendsms*.log >/dev/nullthen echo check_sendsms.sh failed when going down 1>&2 echo See check_sendsms*.log for info 1>&2 exit 1firm check_sendsms*.logexit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -