LoginSignup
1
0

More than 5 years have passed since last update.

curlを連続で叩くperlスクリプト

Posted at

なにかとAPIの使用回数チェックや負荷テストの攻撃したい時に毎回ちょっと忘れるのでメモ。
301回実行の場合

test.pl

#!/usr/bin/perl                                                           

for ( 0..300 ) {                                                          
  system "curl <ここにURL>";
}                                                                         

1;                                                                        
$ perl test.pl

# URL叩いたレスポンスが返ってくる
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">                                
<html><head>                                                                                   
<title>302 Found</title>                                                                       
</head><body>                                                                                  
<h1>Found</h1>                                                                                 
</body></html>                                                                                 

メモ

#!/usr/bin/perl は環境によって違うので適宜書き換え。
どこにperlがいるかは、 whereis perl で探せる。

$ whereis perl
perl: /usr/bin/perl /usr/share/man/man1/perl.1.gz
1
0
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
1
0