LoginSignup
3
1

More than 5 years have passed since last update.

非同期でjsonをcurlでpostするシェルスクリプト

Last updated at Posted at 2018-10-25
curl_exec.sh
URL="http://example.com"
BODY='{"param1":"a","param2":"b"}'
NUMBER_OF_TIMES=10

i=0
while [ $i -lt $NUMBER_OF_TIMES ]
do
  curl -w "\t%{http_code}\t%{time_total}\n" -X POST -H "Content-Type: application/json" -d $BODY $URL &
  i=$((i+1))
done

10回バックグラウンドジョブとしてcurlでコールします。
バックグラウンドなので出力結果はしばらくしてからヌルヌル表示されます。

出力結果:

$ 結果①   200   1.402
結果②   200     2.491

出力結果としてステータスコードとレスポンス時間を出力します。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1