sh script exception: /bin/sh^M:bad interpreter: No such file or directory

from

http://myswirl.blog.163.com/blog/static/51318642201192381444842/

 

 

 

 

Execute .sh script in Linux, exception /bin/sh^M: bad interpreter: No such file or directory

sh script exception: /bin/sh^M:bad interpreter: No such file or directory - myswirl - whirlpool nest

Analysis: This is caused by different system encoding formats. The .sh file edited in the Windows system may have invisible characters, so the above exception information will be reported when executed under the Linux system. 
Solution: 1. Use some editors such as UltraEdit or EditPlus to convert the script code
under Windows , and then put it into Linux for execution.
The conversion method is as follows (UltraEdit): File-->Conversions-->DOS->UNIX. 

sh script exception: /bin/sh^M:bad interpreter: No such file or directory - myswirl - whirlpool nest

 
2 Converting in Linux
2.1 First make sure the file has executable permissions 
#sh>chmod a+x filename 
2.2 Then modify the file format 
#sh>vi filename 
2.3 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 
2.4 Use the following command to modify the file format 
: set ff=unix or: set fileformat=unix 
:wq (save and exit) 
2.5 Finally execute the file 
#sh>./filename

sh script exception: /bin/sh^M:bad interpreter: No such file or directory - myswirl - whirlpool nest

 

sh script exception: /bin/sh^M:bad interpreter: No such file or directory - myswirl - whirlpool nest

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326379275&siteId=291194637