Shell script test basic interface

1. First you need to create a .sh file vi myshell.sh

2. Edit the myshell.sh file

Note that there must be no spaces when defining variables, otherwise it will not take effect

1 #!/bin/sh
2 json_request='{"name":"XX","age":"10"}'
3 hostUrl='http://XXX/XX/XX'
4 post_date=`curl -X POST -H 'content-type:application/json' -d $json_request $hostUrl`#call接口
5 #success=`cat resJson|awk -F"[success]" '/success/{print$3}'`
6 # echo 'the value is' $success
7 for i in {1..10} #for循环从1到10
8 do
9 #if [$post_date =~ "status" || $post_date =~ "true"];then
10 echo "---------------json response----------------- "$i $post_date
11 # echo "----success-----"
12 #else
13 # echo $post_date
14 # echo "----fail-----"1716 done
15 #fi

3. Establish an executable permission for the newly created file

chmod +x myshell.sh

4. Execute the script

sh myshell.sh

 

Guess you like

Origin www.cnblogs.com/echo777/p/12678540.html