我编写了一个脚本,用于在从文件中读取消息后向用户发送消息。
i.e. ./sendxms number " TEST MSG" -P AccountID -O ID
读取所有参数,但在第一个空格
之后截断的消息除外i.e. ./sendxms 123232 "TEST" -P AccountID -O ID
在下面的第一个单词是我的脚本后请截断消息
#!/bin/bash
cd /usr/local/SendXMS
echo "nohup ./sendxms -q1 -aRECEIVE &"
cd /var/mk/Ali_Test
echo enter file name
read fname
exec<$fname
OLD_IFS=$IFS
count=0
while read line
do
count=`expr $count + 1`;
IFS=' '
read var1 var2 <<<"$line"
#echo "$var1"
#echo "$line"
string="\"This is a test message $var2.\""
cd /usr/local/SendXMS
./sendxms +$var1 $string -pSMPP -Otest
cd /var/mk/Ali_Test
sleep 1
done
IFS=$OLD_IFS
echo "Total SMS Sent $count";
答案 0 :(得分:5)
这是因为您没有在命令行中引用参数:
./sendxms +$var1 $string -pSMPP -Otest
将其更改为:
./sendxms +"$var1" "$string" -pSMPP -Otest