jobslsf

How to use $LSB_JOBINDEX to call different scripts?


I know I can pass $LSB_JOBINDEX to a script and then execute the script I actually want based on the index but I would rather do everything in one command.

My scripts are located in a directory like:

Script1

Script2

.

.

.

Script10

I would like to run:

bsub - J myArray[1-10] Script\$LSB_JOBINDEX

Does anyone know if there is a nice way to do this?


Solution

  • The easiest way without getting into a mess with escaping and quoting is just to execute everything from a single script that dispatches to the other ones:

    bsub -J myArray[1-10] dispatcher.sh
    

    where dispatcher.sh looks something like:

    #!/bin/sh
    realscript="Script${LSB_JOBINDEX}"
    eval realscript