Linux shell scripting: bad interpreter: No such file or directory Mon, Sep 15. 2008
This is telling Linux that this script should be interpreted using the /bin/sh program. So your first step is to verify that program exists. I tend to use:
This will typically come back with a response like this:
This is telling us that the path to the sh program is in fact /bin/sh, matching the path specified at the top of the script. Ok, so what gives? Well, it's possible that this script was made on an operating system that has line ending characters different than linux. This could have been on on a Mac or PC, or the file could have been converted when it was packaged. In this case, you get the relatively misleading bad interpreter: No such file or directory message, which is really trying to look for sh
So, how to fix? Read on.
vi is a text based dinosaur in the day of wysiwyg editors, so if you don't know your way around, make sure you follow these steps carefully.
Once the file is loaded type:
And hit Enter/Return.
You won't notice anything, but the file has already been fixed. Now all you need to do is save and exit.
Again Return, and you should be back in your shell. Run the shell script, and if all goes well, it should now execute properly, and without the dreaded bad interpreter: No such file or directory message.
#1 - chrashoverraid 2008-10-14 07:35 - (Reply)
Thank you, i am a linux noob and had this problem!
now its working :)
#2 - .xghost said:
2009-01-29 09:58 - (Reply)
I encountered this problem too. The funny thing is that the script was written in the linux environment. Still had to fix it. No clue as to how it got contaminated with that in the first place :o
#2.1 - OrthodoxCaveman 2012-01-16 18:34 - (Reply)
Happens the same with me, can't find any info on it too...
#6 - Richa Sabharwal 2010-03-01 03:06 - (Reply)
Thanks a ton!! I had the same problem. The script was sent to me as an attachment in the email. The fix worked like a charm for me on Snow Leopard OSX.
#8 - Vladimir Tsukur said:
2010-07-24 07:02 - (Reply)
Thank you. Your post helped me to resolve the issue
#11 - runbux 2010-08-31 20:01 - (Reply)
Didn't work. The Linux file structure is so arbitrary and incomprehensible -- On Purpose! Why can't it just work?
#12 - Anil K said:
2010-12-08 13:34 - (Reply)
its not wokring now, i have a ksh and when i do
:set fileformat=unix
and dos2unix
nothign dint worked for me.
?
- Anil K
#14 - Ravi 2010-12-29 05:26 - (Reply)
Wow......... that was a greate information.. It helped me alot.. Thank you very much....Have a greate day
#15 - Craig Fairhurst said:
2011-02-14 15:21 - (Reply)
Worked, thanks
#16 - Kevin McCaughey said:
2011-06-08 05:24 - (Reply)
Thank you so much!!! I had spent hours trying to get my script to work and eventually stumbled on your blog. How could I be so stupid? lol.
Thanks for taking the time to post this - I'm sure it has helped countless people a HUGE headache :)
#17 - Denver Green 2011-06-08 13:44 - (Reply)
Solved my problem. Thank you for posting this information!!!
#21 - Linux worker 2011-09-08 05:49 - (Reply)
Hi,
I have a problem when I did the following step:
******************
auxin@auxin-DQ45CB:~/Downloads/Propagation1d$ /Chaste.sh ChasteParameters.xml
bash: path_to_chaste: No such file or directory
auxin@auxin-DQ45CB:~/Downloads/Propagation1d$
******************
I don't know how to fix the problem,I tried several method to set path but it didn't work.
I would be happy if you help me to resolve this problem.
#22 - chris said:
2011-09-08 06:35 - (Reply)
Thanks David, you saved me a day's work figuring this out



Tracked: May 12, 03:09
Great article post.Thanks Again. Much obliged.
Tracked: Dec 15, 18:15
Tracked: Jan 02, 06:20