Error message:
Bad interpreter:no such file or directory:/bin/sh
Error Analysis:
Because the operating system is windows, the script is edited under Windows, so there may be non-visible characters.
Workaround:
First, make sure that the file has executable permissions
#chmod a+x filename
Then modify the file format
#vi filename
Use the following command to view the file format
: Set FF or: Set FileFormat
You can see the following information
Fileformat=dos or Fileformat=unix
Use the following command to modify the file format
: Set Ff=unix or: Set Fileformat=unix
: Wq (save to withdraw)
Finally, execute the file.
#./filename
Fortran after a program, but with the original call script how can not be executed, problems such as title, it is best to find this article, suddenly dawned.
Linux the next script can not run, I checked the number of times, there is no mistake. Come on, insane!
Tip: Bad interpreter:no such ref= "tag-870-1.html" >file or directory
On the internet for a long time, finally found that the original file format problem. This file was written by me under Windows.
Line wrapping is not the same as UNIX, but under VI if it is not set a bit and can not be completely visible.
The gas halo passed. I hope no one will be as unlucky as I have spent hours in vain!!
Workaround:
1, the program is seen on a website, I saved, roughly modified a bit.
2, upload to the Linux host to 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 non-visible characters.
From your script and reported errors, it is likely that your script file is in DOS format, that is, each line ends with \ r \ n to identify, the ASCII code is 0x0d, 0x0A.
There are many ways to see if the file is in DOS or UNIX format, or in MAC format.
(1). VI filename
And then use the command
: Set FF?
You can see the Word 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 disk to exit. Run it again and see.
(2). with Joe FileName
In the case of DOS, a lot of green ^m will appear at the end of the line. You can also use the above method to convert it to UNIX format.
(3). With od-t x1 filename
If you see a 0d 0a such characters, then it is in DOS format, if only 0a and not 0d, then it is UNIX format, the same can be used to convert it to UNIX format.
The text file format for converting different platforms can be used
1. Unix2dos or Dos2unix These two small programs to do. Very simple. In DJGPP the names of these two programs are called Dtou and Utod, U is UNIX, D is DOS
2. You can also use tools such as sed to do:
Sed ' s/^m//' filename > Tmp_filename
Mv-f tmp_filename filename
To do
Special Note: ^m is not a key SHIFT + 6 produced by the ^ and the letter M, it is a character, its ASCII is 0x0d, the way to generate it is to first press CTRL + V, then enter (or ctrl+m)
Also, when the Shell Program reports command not found, always check to see if there are any commands in your path that are not being used by the program (the one that does not specify an absolute path). You are such a small program, you can check the line.
Turn dos and Linux format conversion (GO)