Why bad interpreter:no such file or directory occurred

Source: Internet
Author: User
Why bad interpreter:no such file or directory occurred

Linux under a script anyway can not run, I checked several times, can not be wrong. Come on, insane.

Tip: Bad interpreter:no such file or directory

Search on the internet for a long time, finally found that the original file format problem. This file is written by me under Windows.

Line wrapping is not the same as UNIX, but under VI if not set a bit and completely do not see it.

The gas fainted ~ ~ ~ I hope no one will be as unlucky as me, spent several hours in vain!!

Workaround:

1, the program is seen on a website, I saved, roughly modified a bit.

2, upload to Linux host run

chmod +x Back

./back

The error prompts are as follows:
BASH:./back:bad interpreter:no such file or directory

3. Error Analysis:

Because the operating system is windows, I edit the script under Windows, so there may be invisible characters.

From your script and reported errors, it is likely that your script file is in DOS format, that is, the end of each line is identified by/r/n, and its ASCII code is 0x0d, 0x0A.
There are many ways to see whether this file is in DOS or UNIX format, or Mac format
(1). VI filename
Then with command
: Set FF?
You can see the words DOS or UNIX. If it is a DOS format, then you can use set Ff=unix to force it into UNIX format, and then save the file exit. Run it over again and see.
(2). With Joe FileName
if it is in DOS format, there will be a lot of green ^m words in the end of the line. You can also use the above method to turn it into UNIX format.
(3). With od-t x1 filename
If you see a character like 0d 0a, it is in DOS format, if only 0a without 0d, then it is in UNIX format, it can also be used to convert it into UNIX format. The

Convert text file formats for different platforms can be done using the
1. Unix2dos or Dos2unix two small programs. Very simple. In DJGPP, the names of the two programs are Dtou and Utod, and U represents UNIX, and D represents DOS
2. You can also do this with a tool like sed:
sed ' s/^m//' filename > tmp_filename
mv-f tmp_filename filename
To do
Special notes: ^m is not a key shift + 6 produces the ^ and letter M, which is a character whose ASCII is 0x0d, the way to generate it is to press CTRL + V First and then enter (or ctrl+m)

In addition, when the Shell Program reports command not found, Always check your path for every command you have in the program (no absolute path specified). You are so small a program, you can check it line by line.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.