Score
0
Watch 71 Star 334 Fork 72

GVP赵建辉 / rttyCMIT

Join us
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
在任何地方通过web访问您的设备的终端 spread retract

Clone or download
sendcmd.sh 1.02 KB
Copy Edit Web IDE Raw Blame History
Jianhui Zhao authored 2019-01-09 21:45 . Fix sendcmd.sh
#!/bin/sh
host=localhost
port=5912
devid="test"
cmd="echo"
params='["hello rtty"]'
username="test"
password="test"
resp=$(curl -k "https://$host:$port/cmd" -d "{\"devid\":\"$devid\", \"cmd\":\"$cmd\", \"params\": $params, \"username\": \"$username\", \"password\": \"$password\"}" 2>/dev/null)
echo "1:$resp"
token=$(echo "$resp" | jq -r '.token')
[ "$token" = "null" ] && {
echo "$resp"
exit 1
}
while [ true ]
do
resp=$(curl -k "https://$host:$port/cmd?token=$token" 2>/dev/null)
echo "2:$resp"
err=$(echo "$resp" | jq -r '.err')
[ "$err" = "1005" ] && {
echo "Pending..."
sleep 1
continue
}
[ "$err" != "null" ] && {
msg=$(echo "$resp" | jq -r '.msg')
echo "err: $err"
echo "msg: $msg"
break
}
code=$(echo "$resp" | jq -r '.code')
stdout=$(echo "$resp" | jq -r '.stdout' | base64 -d)
stderr=$(echo "$resp" | jq -r '.stderr' | base64 -d)
echo "code: $code"
echo "stdout: $stdout"
echo "stderr: $stderr"
break
done

Comment ( 0 )

Sign in for post a comment

C
1
https://gitee.com/zhaojh329/rtty.git
git@gitee.com:zhaojh329/rtty.git
zhaojh329
rtty
rtty
master

Help Search