私はヘッダーを使用しようとしていますが、bashスクリプトで実行する必要がある作業の簡単な例を提供する方が良いでしょう。
curl ident.me
#this one checks my current public IP address
curl [a post request]
#sending a curl post request
curl ident.me
#again, it checks my current public IP address
curl [a different post request]
#it will send the curl post request ONLY if the IP address we got with the previous curl request is DIFFERENT than the one we got when we previously used the same command to check for the current IP address. If it's not different, it should stop/pause the script.
どんなアイデアがありますか?この質問を技術的かつ正確に定式化することは難しいため、Googleは何の助けも提供していません。
ベストアンサー1
各カールの結果を変数に保存し、各カールの結果を比較して、ifステートメントで互いに一致することを確認します。
a=$(curl ident.me)
curl [a post request]
b=$(curl ident.me)
if [ "$a" != "$b" ]
then
echo "do not match" && ...
else
exit
fi