mirror of
https://github.com/zhaojh329/rtty.git
synced 2026-02-27 09:53:17 +08:00
Usually, commands are executed in batches on multiple devices, but the password for each device is different. Therefore, the password parameter is removed. Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
39 lines
848 B
Bash
Executable File
39 lines
848 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# Your server's host and port
|
|
host=localhost
|
|
port=5913
|
|
|
|
# Your linux device's username and password
|
|
username="test"
|
|
|
|
# Default wait 30s.
|
|
# If you don't care about the results, you can set it to 0, that is, don't wait
|
|
#wait=0
|
|
|
|
devid="test"
|
|
cmd="echo"
|
|
params='["Hello, Rtty"]'
|
|
|
|
|
|
resp=$(curl "http://$host:$port/cmd/$devid?wait=$wait" -d "{\"cmd\":\"$cmd\", \"params\": $params, \"username\": \"$username\"}" 2>/dev/null)
|
|
|
|
[ "$wait" = "0" ] && exit 0
|
|
|
|
err=$(echo "$resp" | jq -r '.err')
|
|
|
|
if [ "$err" != "null" ];
|
|
then
|
|
msg=$(echo "$resp" | jq -r '.msg')
|
|
echo "err: $err"
|
|
echo "msg: $msg"
|
|
else
|
|
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"
|
|
fi
|