Reputation: 5755
I am able to successfully run
/opt/hbase/hbase_current/bin/hbase
on the command line, when connected to a GNU/Linux cluster.
However, when I put this command as a line of a bash script, the error is:
: No such file or directoryopt/hbase/hbase_current/bin/hbase
What am I doing wrong?
When I added a header to the bash script based on the results of "which bash", I get the following error:
bash: ./file.sh: /bin/bash^M: bad interpreter: No such file or directory
The contents of the file are as follows:
#!/bin/bash
ENTITY="'A.B.C'"
HBASE_SHELL="/opt/hbase/hbase_current/bin/hbase"
FILE="A.B.C.txt"
/opt/hbase/hbase_current/bin/hbase
#echo "scan $ENTITY" | $HBASE_SHELL > $FILE
Upvotes: 1
Views: 134
Reputation: 124
It seems you have copied the script from a Windows box. Try dos2unix on the file to remove the Windows line endings:
$ dos2unix file.sh
(sudo apt-get install dos2unix
if you don't have it)
Upvotes: 1
Reputation: 207405
Oh, you have DOS-style CR/LF at the end of your lines. You can see them as they show up as ^M
Do this:
tr -d '\r' < file.sh > newfile.sh
chmod +x newfile.sh
./newfile.sh
The tr
command is started with -d
which means delete all occurrences of whatever follows, which in this case is the sequence representing Carriage Return (CR
).
Upvotes: 2