0

I'm not certain what the problem is with my slurm script - the error messages that I'm receiving are ambiguous redirect for my $input and command not found for when I'm trying to define my variables.

#!/bin/bash
#SBATCH --job-name=gim
#SBATCH --time=24:00:00
#SBATCH --ntasks=20
#SBATCH --ntasks-per-node=2
#SBATCH --cpus-per-task=1
#SBATCH -o output_%A_%a.out #Standard Output
#SBATCH -e output_%A_%a.err #Standard Error

module load program

input= gim${SLURM_ARRAY_TASK_ID}.gjf
output= gim${SLURM_ARRAY_TASK_ID}.log

program $input > $output

The way I run it is:

sbatch --array=1-500 ./slurm.job
EA00
  • 633
  • 8
  • 19
  • `input= foo` is running `foo` as a command with `input` set as an environment variable with an empty value for the duration of that single execution only. – Charles Duffy Jul 13 '16 at 22:37

1 Answers1

2

Whitespace matters:

#!/bin/bash
# ...etc...

input=gim${SLURM_ARRAY_TASK_ID}.gjf
output=gim${SLURM_ARRAY_TASK_ID}.log

program "$input" > "$output"

Note the lack of spaces surrounding the = sign for the assignments. Whitespace matters:

foo = bar # this runs "foo" with "=" as the first argument and "bar" as the second
foo =bar  # this runs "foo" with "=bar" as its first argument
foo= bar  # this runs "bar" as a command with "foo" as an empty string in its environment
foo=bar   # this assigns the value "bar" to the shell variable "foo"
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441