summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-28 01:18:00 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-28 01:18:00 +0000
commitd3bd46ad52c26949d7523b135c22462108c2b297 (patch)
treef589db41bca46a3783fd6f695c7c1f94b1726708
parent974f0c1a06228f90e8ca099c74684fedf513df00 (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-xvest/parallelize.pl17
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 = "";