如何在bash while循环中使用curl ?



我是bash新手,我有一个bash脚本来检查当前服务器状态

while "$(curl --user tc-bot:"$TC_BOT_PASSWORD" -X GET "http://teamcity-server:8111/teamcity/app/rest/server/backup")" == "Running"
do
echo "Backup is running"
sleep 10
done

但我得到line 1: Running: command not found.Curl应该返回Idle状态或Running,我没有关于如何比较Curl输出与我想要的字符串的线索。

不做

while "$(command)" == "Running"

使用

while [ "$(command)" = "Running" ];

注意:首选=而不是==,因为前者是POSIX版本&兼容更多的终端。

最新更新