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.
- PHP Mysql support: mysql or mysqlnd?
- Showing your git branch in your shell prompt
- Centos, Amazon Linux, NFS and the dreaded "nobody" problem
- Run a Centos Lamp development server on XP, Vista or Win 7 using VirtualBox
- Xen 3.0 Fedora Core, RHEL, Centos 4.x How-to
- Install Xwindows and Gnome on Centos with Yum
- Lampsig and SCALE
- Redhat RPM reference notes
Elsa Machado on : Elsa Machado
forums.hardwarezone.com.sg on : PingBack
Confluence: City Girl on : City Girl Development Environment
Thank you, i am a linux noob and had this problem!
now its working :)
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
Happens the same with me, can't find any info on it too...
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.
Thank you. Your post helped me to resolve the issue
Didn't work. The Linux file structure is so arbitrary and incomprehensible -- On Purpose! Why can't it just work?
its not wokring now, i have a ksh and when i do
nothign dint worked for me.
- Anil K
Wow......... that was a greate information.. It helped me alot.. Thank you very much....Have a greate day
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 :)
Solved my problem. Thank you for posting this information!!!
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
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.
Thanks David, you saved me a day's work figuring this out
A million thank-you's. I was editing a file on someone else's system. Being the Linux-challenged person, I had transferred it over to Windows, edited and transferred back. I was going round and around and finally Googled the error message, which brought me here. 3 minutes later I'm back in business. Ginormous Gracias!
I had big problems trying to run python script written under Windows on Debian. I've searched many sites and finally I've found your solution. It is working like a charm. Thank you very much.
the procedure didn't work for me, but I found the reason: the file must not have a BOM, in addition to being in Unix format.
I create my scripts in Notepad++, and it gives the option of saving files in UTF8 format with a BOM, or without a BOM. The BOM adds a few characters at the beginning of the file.
You can check with hexdump:
a file with BOM:
hexdump -C compile_gtk.sh
00000000 ef bb bf 23 21 2f 62 69 6e 2f 73 68 0a 0a 46 49 |...#!/bin/sh..FI|
same file without BOM:
> hexdump -C compile_gtk.sh
00000000 23 21 2f 62 69 6e 2f 73 68 0a 0a 46 49 4c 45 3d |#!/bin/sh..FILE=|
The difference is the first 3 bytes "ef bb bf".
In VI, to check if the file has a BOM, type ":set bomb?". A message "bomb" or "nobomb" should appear.
To remove the BOM, type ":set nobomb", then save the file. Check again with hexdump that the BOM was removed.
Thanks for posting this fix!
Haven't used *nix in a while but it's now slowly becomming a bigger part of my life...
(lots of memory work)
Thank you for posting this. I spent two days of frustration and desperation trying to get a simple cron working. You saved me from losing my mind! :-)
I too faced the same issue. After following ur steps that issue got fixed but now i am getting a new error: "./configure: 2: ./configure: ./aconfigure: not found
Command i run was: ./configure --enable-shared
Unix line endings! working on windows, creating a php file that's not executing properly - spending hours trying to figure out why (because php executes the file properly, but the php interpreter isn't)
Thank you so much!