./configure : /bin/sh^M : bad interpreter [duplica

2019-01-01 04:39发布

This question already has an answer here:

I've been trying to install lpng142 on my fed 12 system. Seems like a problem to me. I get this error

[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
# 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

15条回答
伤终究还是伤i
2楼-- · 2019-01-01 04:57

Use the dos2unix command in linux to convert the saved file. example :

dos2unix file_name
查看更多
美炸的是我
3楼-- · 2019-01-01 05:00

Looks like you have a dos line ending file. The clue is the ^M.

You need to re-save the file using Unix line endings.

You might have a dos2unix command line utility that will also do this for you.

查看更多
流年柔荑漫光年
4楼-- · 2019-01-01 05:05

If you could not found run the command,

CentOS:

# yum install dos2unix*

# dos2unix filename.sh
dos2unix: converting file filename.sh to Unix format ...

Ubuntu / Debian:

# apt-get install dos2unix
查看更多
浮光初槿花落
5楼-- · 2019-01-01 05:07

If you're on OS X, you can change line endings in XCode by opening the file and selecting the

View -> Text -> Line Endings -> Unix

menu item, then Save. This is for XCode 3.x. Probably something similar in XCode 4.

查看更多
牵手、夕阳
6楼-- · 2019-01-01 05:07

Just adding sh before script name make it work in my case.

查看更多
忆尘夕之涩
7楼-- · 2019-01-01 05:10

You can use following command to fix

cat file_name.sh | tr -d '\r' > file_name.sh.new
查看更多
登录 后发表回答