Send batches of data creation requests to http server via Shell

In order to test the data pool volume, send over 60000 creation data to server.
Shell Script:

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
a=1

while [ $a -le 60000 ]; do # start from 1, end by 60000
json="{\"areas\":[{\"new\":[58,60,57],\"id\":\"$a\", \"center\":[-39,49],\"name\":\"$1$a\",\"Version\":\"1.0\"}";

a=$((a+1))

curl -v -X POST -H "Content-Type: application/json; charset=UTF-8" -H "Cookie: sessionId=_____" http://url -d "$json";

done

Mind the syntax especially the space, "" and '', using \ for escaping “” inside json to avoid syntax error.


other materials:

  1. curl 的用法指南