Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have this simple script:

#!/bin/bash
echo ${HADOOP_HOME}
$(hadoop fs -ls)

The output is:

/opt/hadoop-0.20.2-cdh3u2
./hello.sh: line 3: Found: command not found

So bash definitely sees HADOOP_HOME. I've set it in ~/.profile and added path to bin folder:

export HADOOP_HOME="/opt/hadoop-0.20.2-cdh3u2"
export PATH=$PATH:$HADOOP_HOME/bin

If I simply invoke command in console everything works but inside a script it doesn't. What am I doing wrong?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

It's not the problem with echo ${HADOOP_HOME} command.The one which causes the error is $(hadoop fs -ls)

You have to give the 3rd line in that script as echo $(hadoop fs -ls). So the script will look like,

#!/bin/bash
echo ${HADOOP_HOME}
echo $(hadoop fs -ls)

If you give the command like this $(hadoop fs -ls), bash parses it and find it's value. And the founded value is again parsed by bash.

Example:

$ var=4
$ $var
4: command not found
$ echo $var
4

IMO, the value or the output of the command hadoop fs -ls is Found, this string found was again parsed by bash when you give the command like this $(hadoop fs -ls). So that the below error message displayed while executing the script hello.sh,

./hello.sh: line 3: Found: command not found
share|improve this answer
    
Oh, so simple. Thanx a lot! I'll accept answer as soon as I can. –  Moses Apr 29 at 7:43

Your Answer

 
discard

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.