Linux ./configure : /bin/sh^M : 错误的解释器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2920416/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
./configure : /bin/sh^M : bad interpreter
提问by Vineeth Pradhan
I've been trying to install lpng142 on my fed 12 system. Seems like a problem to me. I get this error
我一直在尝试在我的美联储 12 系统上安装 lpng142。对我来说似乎是个问题。我收到这个错误
[root@localhost lpng142]# ./configure
bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory
[root@localhost lpng142]#
How do I fix this? The /etc/fstab
file:
我该如何解决?该/etc/fstab
文件:
#
# /etc/fstab
# Created by anaconda on Wed May 26 18:12:05 2010
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=ce67cf79-22c3-45d4-8374-bd0075617cc8 /boot ext4
defaults 1 2
/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
采纳答案by polymame
To fix, open your script with vi or vim and enter in vi command mode (key Esc), then type this:
要修复,请使用 vi 或 vim 打开脚本并进入 vi 命令模式(键Esc),然后键入:
:set fileformat=unix
Finally save it
最后保存
:x!
or :wq!
:x!
或者 :wq!
回答by Konerak
Your configure file contains CRLF line endings(windows style) instead of simple LF line endings (unix style). Did you transfer it using FTP mode ASCII from Windows?
您的配置文件包含CRLF 行尾(windows 样式)而不是简单的 LF 行尾(unix 样式)。您是否使用 Windows 的 FTP 模式 ASCII 传输它?
You can use
您可以使用
dos2unix configure
to fix this, or open it in vi and use :%s/^M//g;
to substitute them all (use CTRL+V, CTRL+Mto get the ^M)
解决这个问题,或者在 vi 中打开它并用它:%s/^M//g;
来替换它们(使用CTRL+ V、CTRL+M来获得 ^M)
回答by Richard
Looks like you have a dos line ending file. The clue is the ^M
.
看起来您有一个 dos 行结束文件。线索是^M
。
You need to re-save the file using Unix line endings.
您需要使用 Unix 行结尾重新保存文件。
You might have a dos2unix
command line utility that will also do this for you.
您可能有一个dos2unix
命令行实用程序也可以为您执行此操作。
回答by Vern Jensen
If you're on OS X, you can change line endings in XCode by opening the file and selecting the
如果您使用的是 OS X,则可以通过打开文件并选择
View -> Text -> Line Endings -> Unix
查看 -> 文本 -> 行尾 -> Unix
menu item, then Save. This is for XCode 3.x. Probably something similar in XCode 4.
菜单项,然后保存。这适用于 XCode 3.x。XCode 4 中可能有类似的东西。
回答by Somaiah Kumbera
Or if you want to do this with a script:
或者,如果您想使用脚本执行此操作:
sed -i 's/\r//' filename
回答by zuallauz
Following on from Richard's comment. Here's the easy way to convert your file to UNIX line endings. If you're like me you created it in Windows Notepad and then tried to run it in Linux - bad idea.
继理查德的评论之后。这是将文件转换为 UNIX 行尾的简单方法。如果您像我一样在 Windows 记事本中创建它,然后尝试在 Linux 中运行它 - 坏主意。
- Download and install yourself a copy of Notepad++(free).
- Open your script file in Notepad++.
- File menu-> Save As->
- Save as type:
Unix script file (*.sh;*.bsh)
- Copy the new .sh file to your Linux system
- Maxe it executable with:
chmod 755 the_script_filename
- Run it with:
./the_script_filename
- 下载并为自己安装Notepad++(免费)的副本。
- 在 Notepad++ 中打开脚本文件。
- 文件菜单->另存为->
- 保存类型:
Unix script file (*.sh;*.bsh)
- 将新的 .sh 文件复制到您的 Linux 系统
- Maxe it 可执行:
chmod 755 the_script_filename
- 运行它:
./the_script_filename
Any other problems try this link.
任何其他问题试试这个链接。
回答by wu liang
You can use following command to fix
您可以使用以下命令来修复
cat file_name.sh | tr -d '\r' > file_name.sh.new
回答by URB
This usually happens when you have edited a file from Windows and now trying to execute that from some unix based machine.
这通常发生在您从 Windows 编辑了一个文件,现在尝试从某些基于 Unix 的机器上执行该文件时。
The solution presented on Linux Forumworked for me (many times):
Linux 论坛上提出的解决方案对我有用(很多次):
perl -i -pe's/\r$//;' <file name here>
Hope this helps.
希望这可以帮助。
PS: you need to have perl installed on your unix/linux machine.
PS:你需要在你的 unix/linux 机器上安装 perl。
回答by Tjaart
You can also do this in Kate.
您也可以在 Kate 中执行此操作。
- Open the file
- Open the Tools menu
- Expand the End Of Linesubmenu
- Select UNIX
- Savethe file.
- 打开文件
- 打开工具菜单
- 展开行尾子菜单
- 选择UNIX
- 保存文件。
回答by br3nt
Thanks to pwc101's comment on this post, this command worked in Kali Linux .
感谢 pwc101 对这篇文章的评论,这个命令在 Kali Linux 中有效。
sed -i s/{ctrl+v}{ctrl+m}// {filename}
sed -i s/{ctrl+v}{ctrl+m}// {filename}
Make sure you replace the bits in brackets, {}
. I.e. {ctrl+m}
means press Ctrlkey and the Mkey together.
确保替换括号中的位,{}
。即{ctrl+m}
表示同时按下Ctrl键和M键。