shell腳本發(fā)送http請(qǐng)求的實(shí)現(xiàn)示例
簡(jiǎn)述:使用shell腳本發(fā)送http請(qǐng)求,解析請(qǐng)求獲取token再次發(fā)起請(qǐng)求
系統(tǒng):ubuntu系統(tǒng)
工具:cURL(發(fā)送http請(qǐng)求),jq(解析json),沒有需要安裝
host="192.168.1.199"
post="8888"
pre="/api/v1"
url_pre="http://${host}:${post}${pre}"
get_token="curl --location --request GET ${url_pre}/token?access_id=admin&access_secret=123456&="
echo $get_token
token=$($get_token)
echo $token
token=$(echo $token | jq ".data.token")
token=${token:1:-1}
echo $token
curl --location --request POST ${url_pre}/device/runtime_data?token=${token} --header 'Content-Type: application/json' --data-raw '{"id_device": "d2217a3b-dfc0-4301-86f3-78fbb4cb58e4","data_type": ""}'
shell 調(diào)用HTTP POST請(qǐng)求
curl -X POST --header 'Content-Type: application/json' --header 'ReportScript-Sign: FgPlfGlYw83zMdZd' --header 'Accept: application/json' -d '{
"data": {
"appkey": "XXXXX",
"code": "bigdata.platform.XXXXX",
"params": {}
},
"extra": {}
}' 'http://XX.XX.XX.XX:XXXXX/report_api/extraFunction/commonApi'到此這篇關(guān)于shell腳本發(fā)送http請(qǐng)求的實(shí)現(xiàn)示例的文章就介紹到這了,更多相關(guān)shell發(fā)送http請(qǐng)求內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
shell腳本實(shí)現(xiàn)一鍵獲取linux內(nèi)存/cpu/磁盤IO信息
這篇文章主要為大家詳細(xì)介紹了如何通過shell腳本實(shí)現(xiàn)一鍵獲取linux內(nèi)存/cpu/磁盤IO等信息,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解下2024-12-12
探究正常運(yùn)行的shell腳本為啥有時(shí)會(huì)報(bào)錯(cuò)
正常運(yùn)行的shell腳本為啥有時(shí)會(huì)報(bào)錯(cuò)呢,這篇文章主要就是來和大家探索一下報(bào)錯(cuò)的原因以及解決方法,感興趣的小伙伴可以跟隨小編一起了解一下2023-08-08
利用Linux中的crontab實(shí)現(xiàn)分布式項(xiàng)目定時(shí)任務(wù)功能
crond是Linux用來定期執(zhí)行程序的命令.這篇文章主要介紹了利用Linux中的crontab實(shí)現(xiàn)分布式項(xiàng)目定時(shí)任務(wù),需要的朋友可以參考下2018-01-01

