curl post的shell

outputfile="/home/app/java_trans/"
cd $outputfile
#得到command执行结果 sourceMobile
=$(awk '{print $0}' output.txt |xargs |sed 's/ /\\",\\"/g') #echo $sourceMobile mobiles="\"[\\\"${sourceMobile}\\\"]\"" #echo $mobiles #mobiles2="\"[\\\"9TDYwD2BqLVpx6/4LpQ==\\\",\\\"wE2xSOYDCHt/TcqU/A==\\\"]\"" #echo $mobiles2
#字符串拼接 bodydata
="'{\"fileName\":\"A40320200925163333000130_2000.txt\",\"flag\":\"0\",\"data\":${mobiles}}'" url="https://badi/yzfdafdf/send" #echo $bodydata posturl="curl -H \"Content-Type:application/json\" -X POST -d ${bodydata} ${url}" echo $posturl eval $posturl #curl -H "Content-Type:application/json" -X POST -d '{"fileName":"A40320200925163333000130_2000.txt","flag":"0","data":"[\"9TDYwD2BqLVpxe/4LpQ==\",\"wE2xSOYDCHUHXncqU/A==\"]"}' https://badi/yzfdafdf/send

 参考了这个文章

查看二

 

curl测试某个网址是否正常访问:

echo "***********运行命令开始***************"
All_COUNT=0
SUCCESS_COUNT=0
FAIL_COUNT=0
for line in `cat input.txt`
do
    All_COUNT=$(($All_COUNT+1))
    echo $line
    curl -i $line 2>/dev/null|grep "xxxxx"
    if [ $? -ne 0 ] ;then
        echo "grep not found xxxxx"
        FAIL_COUNT=$(($FAIL_COUNT+1)) 
    else
        echo "grep get xxxxx"
        SUCCESS_COUNT=$(($SUCCESS_COUNT+1))
    fi
    sleep 2s
done
timeStr=$(date "+%Y-%m-%d %H:%M:%S")
echo $timeStr" 总计测试:"$All_COUNT" ,其中成功:"$SUCCESS_COUNT" ,其中失败: "$FAIL_COUNT >> result.txt
echo "***********命令运行结束*******************"

 

posted @ 2020-12-29 11:34  zhucezmf  阅读(299)  评论(0编辑  收藏  举报