Skip to main content

Posts

Showing posts from February, 2015

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

While running some sh scripts i faced the below issue.
[biadmin@illinxxxx scripts]$ ./nftp_vals.sh ./nftp_vals.sh: ./nftcontroller.sh: /bin/bash^M: bad interpreter: No such file or directory ./nftp_vals.sh: ./throughput_and_latency.sh: /bin/bash^M: bad interpreter: No such file or directory ./nftp_vals.sh: ./detailedreport.sh: /bin/bash^M: bad interpreter: No such file or directory ./nftp_vals.sh: ./nftreader.sh: /bin/bash^M: bad interpreter: No such file or directory

Cause: This issue is caused when creating scripts in Windows env and then porting over to run on a unix environment.
Unix uses different line feeds and carriage returns so can't read the file you created on Windows. Hence it is seeing ^M as an illegal character.

Resolution: Just run dos2unix -k -o <filename> and the issue will be fixed.
E.g.:
[biadmin@illinxxxx scripts]$ dos2unix -k -o nftcontroller.sh dos2unix: converting file nftcontroller.sh to UNIX format ...

[biadmin@illinxxxx scripts]$


By using the below command we can …