LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shell problem -- Bad Interpreter (https://www.linuxquestions.org/questions/linux-newbie-8/shell-problem-bad-interpreter-4175454435/)

wgl3Dev 03-17-2013 01:52 PM

Shell problem -- Bad Interpreter
 
Upon trying to execute a shell script in the current directory via. "./shellcommand" I get the message:
bash: ./gitk-wish: /bin/sh^M: bad interpreter: No such file or directory

It worked at one point and I am sure it involves a setting I somehow messed up. But look as I might I can't seem to find it.

It is very annoying and prevents me from running shell scripts. Any guidance would be appreciated.

fl0 03-17-2013 02:00 PM

hi,

please do
Code:

cat -A gitk-wish
and look at control sequences (the /bin/sh^M ) looks like a control sequence. Eleminate all Control Sequences.

Have you created the script on windows? Try dos2unix command.

regards fl0

shivaa 03-17-2013 02:23 PM

Check what's script sha-bang i.e. is it #!/bin/bash?

Just modify your script interpreter i.e. sha-bang to #!/bin/bash or #!/bin/sh (Just remove ^M character from it).

Also once run your script with set -xv to check where it throws error...

suicidaleggroll 03-17-2013 03:56 PM

Your file has DOS end of line terminators (that's what the ^M on the end of the line means), you need to convert it to Linux. Most distributions have the "unix2dos" and "dos2unix" programs, which you can use with:
Code:

dos2unix gitk-wish
This is a common problem if you create your script on a Windows machine and then copy it over.

wgl3Dev 03-18-2013 09:04 AM

Thanks
 
Problem solved.

Script had control characters from DOS creation. Got them from a clone of git.
Did a "sudo yum install dos2uninx" and converted the file using: "dos2unix gitk-wish". Works great.. Thanks for your help!

wgl3Dev 03-18-2013 03:11 PM

Is there anyway to convert a whole arch (tar.ball or git clone)?


All times are GMT -5. The time now is 11:40 PM.