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

.Sh script execution in Linux, abnormal / bin / sh ^ M: bad interpreter: No such file or directory.

This is caused by a different system encoding formats: edit in Windows systems .sh file may have invisible character in the Linux system to execute the above exception information will be reported.

Solution:

1) conversion under Windows

Use some editor, such as UltraEdit or EditPlus tools such as transcoding script first, then into the Linux execution. Conversion follows (UltraEdit): File -> Conversions -> DOS -> UNIX can be.

2) conversion in Linux

First make sure the file executable permissions

chmod a+x filename

Then modify the file format

vi filename

Use the following command to view the file format

:set ff 或 :set fileformat

We can see the following information

fileformat=dos 或 fileformat=unix

Use the following command to modify the file format

:set ff=unix 或 :set fileformat=unix(别忘了按回车)

: Wq (press enter, save and exit)

Finally, you can perform file

./filename

Original: http: //www.cnblogs.com/pipelone/archive/2009/04/17/1437879.html

Guess you like

Origin www.cnblogs.com/kkvt/p/11606201.html