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} 控制额外输出
#!/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} 控制额外输出