天天看点

perl 中用shell.pm调用shell命令

perl 中用shell.pm调用shell命令

code:

#!/usr/bin/perl -w 

use strict; 

use Shell qw/webbench/; 

my @array = (); 

open FILE,'<','url.txt' or die "$!\n"; 

while (<FILE>) { 

       chomp; 

       /(\S+)/; 

       push @array,$1; 

close FILE; 

while (1) { 

       for my $url (@array) { 

           my $sh = Shell->new; 

           print $sh->webbench("-c 500 -t 60 $url"); 

       } 

sleep 5 

 本文转自dongfang_09859 51CTO博客,原文链接:http://blog.51cto.com/hellosa/507906,如需转载请自行联系原作者