1

I am using Grid Engine on a Linux cluster. I am running many jobs with different programs and different input files. I don't want to create multiple specific job scripts for each pair of program and input file. Instead I want to be able to specify the program name and the input file on the qsub line.

Therefore I can use qsub job.sh <programNameAndLocation> <inputFileName>

Where job.sh takes two arguments. This works fine. But there is another twist: my programs are located in a very very long directory which I don't want to type every time I submit a job - so aliases are an obvious choice.

So I want to do something like qsub job.sh <programNameAndLocationAlias> <inputFileName>

I initially set the alias in my .bashrc but was getting the error: <programNameAndLocationAlias>: command not found

So I set the alias in submit.sh. But I am getting the same error.

Thoughts on how can I can get the command qsub job.sh $1 $2 to accept aliases also?

5
  • What shell are you using? (this is probably better solved by a function that does a lookup, not an alias)
    – thrig
    Commented Jan 19, 2017 at 19:15
  • I'm using bash (tag added). I should be looking in to indirect referencing a la ${!<programNameAndLocation>} then?
    – cyuut
    Commented Jan 20, 2017 at 10:11
  • I have tried using indirect expansion so my input line becomes qsub job.sh ${!<programNameAndLocationParameter>} <inputFileName>. I am setting my parameter in my .bashrc via export <programNameAndLocationParameter>=<programNameAndLocation>. Now however I am getting an error which is telling me that bash is trying to execute my input file and it is not being read by my program. Any thoughts?
    – cyuut
    Commented Jan 20, 2017 at 10:45
  • Okay, but what is programNameAndLocationParameter? A path? Two or more arguments?
    – thrig
    Commented Jan 20, 2017 at 18:26
  • <programNameAndLocationParameter> is a path and program name. e.g. /exports/programs/solver where "solver" is my program to be executed. The executed program itself accepts one argument. Which is the input file path and name (<inputFilName>).
    – cyuut
    Commented Jan 21, 2017 at 19:21

1 Answer 1

0

A hash and a lookup function might look something like

#!/usr/bin/env bash

declare -A proggies

# "aliases" and then the path said should expand to
proggies[foo]=/some/big/long/stupid/path/foo
proggies[bar]=/some/big/long/stupid/path/bar

function qrunner {
    local exe
    exe=${proggies[$1]}
    if [[ -z "$exe" ]]; then
        echo >&2 "no mapping for '$1'"
        return 1
    fi
    # echo here is for debugging, remove when ready to
    # really break things
    echo qsub job.sh "$exe" "$2"
}

# positive test
qrunner bar filename
echo $?

# and also a negative one
qrunner nope filename
echo $?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .