diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-06-28 01:18:00 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-06-28 01:18:00 +0000 |
commit | d3bd46ad52c26949d7523b135c22462108c2b297 (patch) | |
tree | f589db41bca46a3783fd6f695c7c1f94b1726708 | |
parent | 974f0c1a06228f90e8ca099c74684fedf513df00 (diff) |
run netstat once only, and w/ windows compat options
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@34 ec762483-ff6d-05da-a07a-a48fb63a330f
-rwxr-xr-x | vest/parallelize.pl | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/vest/parallelize.pl b/vest/parallelize.pl index 7a4a2133..45152144 100755 --- a/vest/parallelize.pl +++ b/vest/parallelize.pl @@ -29,6 +29,9 @@ my $verbose = 1; my $numnodes; my $user = $ENV{"USER"}; my $pmem = "2g"; +my $basep=50300; +my $randp=300; +my $tryp=50; sub print_help; @@ -41,7 +44,9 @@ if (GetOptions( "file=s" => \@files_to_stage, "verbose" => \$verbose, "jobs=i" => \$numnodes, - "pmem=s" => \$pmem + "pmem=s" => \$pmem, + "baseport=i" => \$basep, + "iport=i" => \$randp, #ugly option name so first letter doesn't conflict ) == 0 || @ARGV == 0){ print_help(); } @@ -89,13 +94,14 @@ $executable=`basename $executable`; chomp $executable; # find open port -my $basep=50300; -my $randp=300; -my $tryp=50; +srand; my $port = 50300+int(rand($randp)); my $endp=$port+$tryp; +my $netstat=`netstat -a -n 2>/dev/null | grep LISTENING | grep -i tcp`; + if ($verbose){ print STDERR "Testing port $port...";} -while (`netstat -ln 2>/dev/null | grep $port`){ + +while ($netstat=~/$port/s){ if ($verbose){ print STDERR "port is busy\n";} $port++; if ($port > $endp){ @@ -107,7 +113,6 @@ if ($verbose){ print STDERR "port $port is available\n"; } -srand; my $key = int(rand()*1000000); my $multiflag = ""; |