[padb] r330 committed - Specify the full and correct path to padb when launching the inner...

padb at googlecode.com padb at googlecode.com
Tue Nov 24 11:17:35 GMT 2009


Revision: 330
Author: apittman
Date: Tue Nov 24 03:17:18 2009
Log: Specify the full and correct path to padb when launching the inner
command instead of simply using $0.  Based on a patch from
Thipadin Seng-Long @ Bull.

http://code.google.com/p/padb/source/detail?r=330

Modified:
  /trunk/src/padb

=======================================
--- /trunk/src/padb	Thu Nov 12 07:14:50 2009
+++ /trunk/src/padb	Tue Nov 24 03:17:18 2009
@@ -4657,6 +4657,32 @@
      print "Failed to load secret from file ($file)\n";
      exit 1;
  }
+
+# Find the path to use for padb, previously we just used $0 here however
+# when using pdsh to find jobs $PWD isn't preserved between the inner and
+# the outer so we have to search out the real location of padb.  It would
+# be possible to do this on request, that is only for pdsh rather than
+# globally however there should be no down-side to always executing this.
+# Based on a patch from Thipadin Seng-Long @ Bull.
+
+sub padb_path {
+    my $pwd   = $ENV{PWD};
+    my $dirnm = dirname($0);
+
+    # if padb is launch as padb then dirname is .
+    # if padb is launched with a full path then dir is full
+    # if padb is launched as ../padb then dir is ..
+    # if padb is launched as Dir/padb then dir is Dir
+    my $out;
+    if ( $dirnm eq "." ) {    # started in current dir
+        my $base = basename($0);
+        return "$pwd\/$base";
+    } elsif ( $dirnm =~ m{\A/}x ) {    # started as full path or path known
+        return $0;
+    }
+
+    return "$pwd\/$0";
+}

  sub go_job {
      my $jobid = shift;
@@ -4692,7 +4718,7 @@
      debug_log( 'verbose', undef, 'There are %d processes over %d hosts',
          $ncpus, $nhosts );

-    $cmd .= " $0 --inner";
+    $cmd .= " " . padb_path() . " --inner";

      if ( $conf{inner_callback} ) {
          $secret = find_padb_secret();




More information about the padb-devel mailing list