Skip to content

Instantly share code, notes, and snippets.

@yukari-n
Created June 1, 2019 10:31
Show Gist options
  • Select an option

  • Save yukari-n/525ccc15423a5eeef3af11da80e22917 to your computer and use it in GitHub Desktop.

Select an option

Save yukari-n/525ccc15423a5eeef3af11da80e22917 to your computer and use it in GitHub Desktop.
連続アクセスしたいときに使うやつ(悪用はやめましょう)
#!/bin/bash
# $1 = 叩く回数
# $2 = "叩きたいURL"
# 確実に叩きたいのでステータスコードが200じゃなかった分は数を引いています。
# 落ちてるサーバーに何回もアクセスしてもしょうがないけど今回必要な数だと20秒もあれば終わってしまうので途中で止めなくても良いかなという感じ。
if [ $# -ne 2 ]; then
echo "引数足りてないです"
elif [ $1 -gt 150 ]; then
echo "悪用はやめましょう"
else
echo "処理開始"
ecount=0
for i in `seq 1 $1`
do
# echo $i
status=`curl -s $2 -o /dev/null -w "%{http_code}"`
if [ $status = "200" ]; then
sleep 0.1s
else
echo $status
ecount=$(( ecount + 1 ))
fi
done
count=`expr $1 - $ecount`
echo "$count 回叩きました"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment