Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following Sun Grid Engine submission script:

# 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

echo "current working directory: $currentdir"

And here is my output

currentdir: Undefined variable.

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

How to fix this?

share|improve this question
Your sure that /bin/pwd is correct? Does it work when invoked manually? – Bobby Sep 19 '12 at 12:39
The fact that the script output the current directory (/home/eamorr/sge) suggests that it is finding pwd. And, even if not, it shouldn't cause this error; foo=`/no/such/command` should still either assign a null string to foo or abort the script. – Scott Sep 19 '12 at 20:39

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
share|improve this answer
Hi, thanks for the comment. I'm not sure it's bash... I tried currentdir=$(/bin/pwd), but it returned Illegal variable name – Eamorr Sep 19 '12 at 12:00
So it's most likely not bash. Try option (1) then, but actually, it probably uses a proprietary SUN shell which just behaves completely different from other known shells. – Stefan Seidel Sep 19 '12 at 12:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.