Shell script error – bad interpreter messages and solution

by Vivek Gite on November 8, 2006 · 3 comments

. I have downloaded some shell script but when I try to run these shell scripts I get error bad interpreter... How do I fix this error?

A. Make sure you have required shell installed. Each shell script specifies default interpreter at top of the script. For example, consider following script:
#!/bin/sh
# This is...
clear
A=`pwd`
...
.....
...

#!/bin/sh is default interpreter to execute this script. Use ls command to verify that you have /bin/sh installed
$ ls /bin/sh

If /bin/sh is not installed, use rpm, up2date or apt-get command to install required shell.

Another problem is if script was edited or written on MS-DOS platform, you will see CR/CRLF in script. Use dos2unix command to convert theses scripts to UNIX format.
dos2unix script-file-name

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 3 comments… read them below or add one }

1 gautam rampal February 23, 2009

thanks a lot my problem got solved, i tried all the ways when i used dos2unix it worked, I forgot that i edited the script previously in windows.

Reply

2 Cui August 11, 2009

where do you use dos2unix?
I could not use it in command prompt and in unix
is there a dos2linux command?
thanks!

Reply

3 Mitra October 21, 2011

Thanks alot…it saves lot of time…

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 10 + 8 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.



Previous post:

Next post: