Friday, June 24, 2016

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


Very simple thing but sometimes it will bother you a lot.

I tried to run a shell script  “daily_full_expdp_backup.sh” but it was giving me following error

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

Solution was:

  Need to execute following script to clean up windows formatting things (spaces) and make it pure linux formated script. after executing following command (with the script) it worked perfectly.see in below screenshot.

  
$sed -i -e 's/\r$//' daily_full_expdp_backup.sh

Explanation:  The ^M is a carriage return character. Linux uses the line feed character to mark the end of a line, whereas Windows uses the two-character sequence CR LF. Your file has Windows line endings, which is confusing Linux. Remove the spurious CR characters using  sed -i -e 's/\r$//'

Please see in below image.



5 comments:

JNahin said...

OMG! You are a life saver, thanks a kabillion!

JNahin said...

OMG! You are my hero!

Unknown said...

set fileformat=unix it is just the file formating

Anonymous said...

set fileformat=unix execute this inside the script. it will allow you to execute the script.

Unknown said...

thank you so much - this worked for me in one of the issue that i faced.