···
#!/bin/bash
exe(){
rowNum=$(awk 'END{print NR}' xxxx/out)
comm=$1
diff=$2
#echo "comm="$1
count=5
#echo "rowNum="$rowNum
while [ $count -gt 0 ]
do
count=`expr $count - 1`
if [ $count -eq 4 -o $3 = "null" ]
then
echo "comm=$comm,count=$count"
#$comm
echo -e $comm > /dev/ttyUSB2
else
echo "comm=$3,count=$count"
echo -e $3 > /dev/ttyUSB2
fi
sleep 10
echo "rizhi"
echo "1--"$(awk 'END{print}' xxx/out)
echo "2--"$diff
echo "3--"$(awk 'END{print NR}' xxx/out)
echo "4--"$rowNum
echo "rizhi"
if [ $(awk 'END{print NR}' xxxx/out) -gt $rowNum ]
then
var1=$(awk 'END{print}' xxxx/out)
echo "jinruif"$var1
echo "jinruif"$diff
if [[ $var1 == *$diff* ]]
then
echo "break"
break
fi
if [[ $var1 == *"ME"* ]]
then
echo "break"
break
fi
fi
rowNum=$( awk 'END{print NR}' xxxx/out )
done
echo ”------------------------“
echo "rowNum=" $rowNum
echo "out="$( awk 'END {print}' xxxxx/out )
echo "count=" $count
echo ”-----“
}
sleep 2
ps aux | grep “cat /dev/ttyUSB2” | tr -s ’ '| cut -d ’ ’ -f 2 | xargs kill -9
cd xxx
rm -rf ./out
echo “start” >> ./out
cat /dev/ttyUSB2 >> ./out &
sleep 5
清除已有短信
exe “AT+CMGD=1,4\r\n” “OK” “null”
获取号码
exe “AT+CNUM\r\n” “OK” “null”
phone=
(
t
a
i
l
−
n
3
o
u
t
∣
h
e
a
d
−
1
)
e
c
h
o
"
p
h
o
n
e
=
"
(tail -n 3 out | head -1) echo "phone="
(tail−n3out∣head−1)echo"phone="phone
phone=
p
h
o
n
e
:
12
:
11
e
c
h
o
"
p
h
o
n
e
=
"
{phone:12:11} echo "phone="
phone:12:11echo"phone="phone
sleep 1
result=
(
c
u
r
l
"
h
t
t
p
:
/
/
x
x
x
/
q
u
e
r
y
S
m
s
I
n
f
o
B
y
P
h
o
n
e
N
u
m
?
p
h
o
n
e
N
u
m
=
"
(curl "http://xxx/querySmsInfoByPhoneNum?phoneNum="
(curl"http://xxx/querySmsInfoByPhoneNum?phoneNum="phone)
echo "result="
r
e
s
u
l
t
a
r
r
=
(
result arr=(
resultarr=({result//,/ })
operatorNum=
a
r
r
[
0
]
b
i
l
l
=
{arr[0]} bill=
arr[0]bill={arr[1]}
dataPlan=
a
r
r
[
2
]
m
e
s
s
a
g
e
=
{arr[2]} message=
arr[2]message={arr[3]}
echo "operatorNum="
o
p
e
r
a
t
o
r
N
u
m
e
c
h
o
"
b
i
l
l
=
"
operatorNum echo "bill="
operatorNumecho"bill="bill
echo "dataPlan="
d
a
t
a
P
l
a
n
e
c
h
o
"
m
e
s
s
a
g
e
=
"
dataPlan echo "message="
dataPlanecho"message="message
发送查话费短信
exe “AT+CMGF=1\r” “OK” “null”
exe “AT+CSCS=“GSM”\r” “OK” “null”
exe “AT+CMGS=”“$operatorNum”“\r\n” “>” “null”
exe $bill"\x1A" “OK” “\x1A”
sleep 20
#发送查流量短信
exe “AT+CMGF=1\r” “OK” “null”
exe “AT+CSCS=“GSM”\r” “OK” “null”
exe “AT+CMGS=”“$operatorNum”“\r\n” “>” “null”
exe $dataPlan"\x1A" “OK” “\x1A”
sleep 20
#查询短信
exe “AT+CMGF=1\r\n” “OK” “null”
exe “AT+CMGL=“ALL”\r\n” “OK” “null”
flyNum=
(
t
a
i
l
−
n
6
x
x
∣
h
e
a
d
−
1
)
f
l
y
N
u
m
=
(tail -n 6 xx | head -1) flyNum=
(tail−n6xx∣head−1)flyNum={flyNum:16:8}
echo “flyNum=”$flyNum
echo
f
l
y
N
u
m
"
,
"
flyNum","
flyNum","phone","
m
e
s
s
a
g
e
>
>
.
/
o
u
t
m
1
=
message >> ./out m1=
message>>./outm1=(base64 ./out)
m2=$(echo KaTeX parse error: Double superscript at position 11: m1 | tr ' '̲ '+') echo "m2=…m2
curl “http://xxxx/putMessage?message=”$m2
···