bash: ./sqoop.sh: /bin/bash^M: bad interpreter: No such file or directory

bash: ./sqoop.sh: /bin/bash^M: bad interpreter: No such file or directory

I was trying to run a script named sqoop.sh. I got this:

bash: ./sqoop.sh: /bin/bash^M: bad interpreter: No such file or directory

 

Googling online, it is probably due to an extra carriage return at the end of the first line.

Use the command line:

$ head -1 sqoop.sh | od -c

I saw:

0000000 # ! / b i n / b a s h \r \n

There was an extra \r in the command line. This normally happens when editing the script in windows. Obviously I needed to remove “\r”. I opened the script with MS Word, and saved the script as a plain txt file. A window pop up when I clicked “save as”, and some settings need to be decided before saving the file.
For the “end line with” I selected “LF only” (not CR/LF). The following image shows some other settings:

Capture

The file was Ok after re-saving.

Run

$ head -1 sqoop.sh | od -c

Again, I saw:

0000000 # ! / b i n / b a s h \n

Then I could run the scripts. You can also use some other method to remove the “\r”.

 

 

 

Advertisements

About zephyr9000

Happy sailer
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s