bob the dog

# run a command possibly via batch
# 1st param: Job Name
# 2nd param: Depends string
# remainder: command
sub do_cmd_batch {
   my($name, $depends, $logdir);
   $name = shift(@_);
   $depends = shift(@_);

   $logdir = "$opt{'workdir'}/log";
   &do_cmd('mkdir', '-p', $logdir) if (!-e $logdir);

   print STDOUT "[$name:$depends] - @_\n" if $opt{verbose};
   if(!$opt{fake}){

      if($opt{'batch'}){
         print '   [B] ';
         &do_cmd('mkdir', '-p', "$logdir/$$");
         &do_cmd('qbatch',
                 '-logfile', "$logdir/$$/$name.log",
                 '-N', $name,
                 '-depends', $depends,
                 '--',
                 @_);
         }
      else{
         &do_cmd(@_);
         }
      }
   }

Advertisements