search cancel

Error: "-bash /bin/sh^M: bad interpreter: No such file or directory"

book

Article ID: 161726

calendar_today

Updated On:

Products

Encryption Management Server

Issue/Introduction

Upon attempting to run a .sh script, the following error occurs:

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

Cause

The script is not using Unix characters or not formatted for use with a Unix Operating System.

Environment

  • RHEL/CentOS 6.5+
  • OSX 10.9+

Resolution

Run the following command from the Terminal in the directory that the .sh file is located:

dos2unix example.sh example_fixed.sh

Attempt to re-run the .sh file and this time the '-bash ./example.sh /bin/sh^M: bad interpreter: No such file or directory' error will not occur.

If the command is unrecognized by the installation of OSX being used, then the attached application can be installed for the Terminal command to function. (dos2unix-5.3.3-0.pkg) The latest version of this application can be downloaded at the following link which is also the source:

https://code.google.com/p/rudix/downloads/detail?name=dos2unix-5.3.3-0.pkg

Attachments

dos2unix-5.3.3-0.pkg get_app