shell 发送Post请求,并获取状态码

#!/bin/bash

aa=$1
result=$(curl -H "Content-type: application/json" -X POST -o /dev/null -s -w %{http_code} -d '[{"aa":"'${aa}'","bb":"0","cc":"0"}]' URL)
echo $result

-o /dev/null 屏蔽原有输出信息

-s silent

-w %{http_code} 控制额外输出

posted on 2017-10-11 14:32  斜月三星一太阳  阅读(3197)  评论(0编辑  收藏  举报