1

I have the following Sun Grid Engine submission script:

#!/bin/sh
# sun grid engine cluster

# use current working directory
#$ -cwd

# merge error output into standard output stream
#$ -j yes
#$ -o generate_databases.log

# request to  cpu number
#$ -pe make 4

currentdir=`/bin/pwd`
echo "current working directory: $currentdir"

And here is my output

/home/eamorr/sge
currentdir: Undefined variable.

As you can see, the 'currentdir' variable returns undefined.

How to fix this?

fixer1234
  • 28,064
Eamorr
  • 227

1 Answers1

1

Are you sure it's bash? The backtick operator is not portable. There are several ways to (possibly) fix this:

  1. use #!/bin/bash in the first line to make dure it's bash not anything else
  2. avoid the backticks: currentdir=$(pwd) or currentdir=$(/bin/pwd)
  3. or even simpler currentdir=$PWD
Stefan Seidel
  • 10,855