我使用curl编写了一个shell脚本来获取APIKEY并将其通过密钥中的curl动态变量传递,但是我遇到了错误
jq: error (at <stdin>:0): Cannot iterate over number (400)
该错误是由以下原因引发的:
#/bin/bash
echo " Please enter the API Key";
apikey=$(curl -i --silent -u useranme:passwd https://api.ABC.net/auth -k | grep -i X-Api-Key |cut -d\ -f 2);
echo $apikey;
echo " Please enter the VAC value to patch";
read DOW;
curl -s https://api.ABC.net/vac/api/v1/search/servers\?status\="/(i).*active.*/"\&updates_window\=$DOW-America_Los_Angeles\&updates_window_disable\=false\&updates_window_skip_next\=false\&updates_last_status="completed_failed" -H "Authorization: $apikey" -k | grep -e fqdn;
在执行脚本时,未传递$apikey
变量,并且curl不执行。