Search code examples
bashlsf

call bash function with bsub lsf within bash script


I have a bash function i would like to bsub. It is recursively called when i try to source the script, but if i don't source the script it doesn't seem to recognize my function. How do I correctly call besub on a function within the same script file?

my_script(should print "12345"):

#! /bin/sh
function myFunct {
echo $1
}

bsub -q myQueue "source ./my_script; myFunct 12345"

Solution

  • a.bash may look like this

    #! /bin/bash
    
    export input=$1
    function myFunct {
    echo "$input"
    }
    
    # This is if you want to call bsub outside the bash
    #  Use bsub -q Queue `./a.bash 12345`
    
    myFunct "$input"  
    
    
    # Put bsub inside and call the script
    # ./a.bash 12345
    
    bsub -q myQueue `myFunct "$input"`