Changeset 77 for trunk/oarutils


Ignore:
Timestamp:
May 30, 2012, 1:59:59 PM (12 years ago)
Author:
g7moreau
Message:
  • Add support for job name
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oarutils/oar-parexec

    r76 r77  
    7575   my $job_num = 0;
    7676   open(JOB_LIST, '<', "$file") or die "error: can't open job file $file: $!";
    77    while (<JOB_LIST>) {
    78       chomp;
    79       next if m/^#/;
    80       next if m/^\s*$/;
     77   while (my $job_cmd = <JOB_LIST>) {
     78      chomp $job_cmd;
     79      next if $job_cmd =~ m/^#/;
     80      next if $job_cmd =~ m/^\s*$/;
    8181      $job_num++;
    82       push @job, { name => $job_num, cmd => "$_" };
     82      my ($job_name) = $job_cmd =~ m/#.*?\bname=(\S+?)\b/i;
     83      $job_name ||= $job_num;
     84      push @job, { name => $job_name, cmd => "$job_cmd" };
    8385      }
    8486   close JOB_LIST;
     
    327329the first valid job in the list will have the number 1 and so on...
    328330
     331It's possible to fix the name inside a comment on the job line.
     332For example:
     333
     334 $HOME/test/subjob1.sh # name=subjob1
     335
     336The key C<name> is case insensitive,
     337the associated value cannot have a space...
     338
    329339=item B<-d|--dir foldertoiterate>
    330340
     
    414424Example where F<$HOME/test/subjob1.sh> is a shell script (executable).
    415425
    416  $HOME/test/subjob1.sh
    417  $HOME/test/subjob2.sh
    418  $HOME/test/subjob3.sh
    419  $HOME/test/subjob4.sh
     426 $HOME/test/subjob01.sh  # name=subjob01
     427 $HOME/test/subjob02.sh  # name=subjob02
     428 $HOME/test/subjob03.sh  # name=subjob03
     429 $HOME/test/subjob04.sh  # name=subjob04
    420430 ...
    421  $HOME/test/subjob38.sh
    422  $HOME/test/subjob39.sh
    423  $HOME/test/subjob40.sh
     431 $HOME/test/subjob38.sh  # name=subjob38
     432 $HOME/test/subjob39.sh  # name=subjob39
     433 $HOME/test/subjob40.sh  # name=subjob40
    424434
    425435These jobs could be launch by:
Note: See TracChangeset for help on using the changeset viewer.