[英]32 bit linux executable failing with Exec format error. Binary file not executable
[英]Exec format error. Binary file not executable
我在
Linux version 3.3.4-5.fc17.x86_64 (mockbuild@x86-14.phx2.fedoraproject.org) (gcc version 4.7.0 20120504 (Red Hat 4.7.0-4) (GCC) ) #1 SMP Mon May 7 17:29:34 UTC 2012
尝试运行具有权限775且包含以下内容的基本可执行脚本script.ksh文件:
#!/bin/ksh
echo "hello ya"
但我有:
$./script.ksh
./script.ksh: Exec format error. Binary file not executable.
问题看起来像是来自shebang,但我不知道原因和方式。 我可以这样做来运行脚本(注意第一行的输出很奇怪):
$ ksh script.ksh
script.ksh[1]: ?o?;??#!/bin/ksh: not found [No such file or directory]
hello ya
一些(也许)有用的输出:
$ file script.ksh
script.ksh: Korn shell script, UTF-8 Unicode (with BOM) text executable
$ which ksh
/bin/ksh
你有想法吗?
好的,问题出在选项上
set bomb
在vim的.vimrc配置文件中。 评论此行解决问题。
第一行以一些不可见的字符开头,如错误消息中所示:
?o?;??#!/bin/ksh
:找不到
您可以通过以下方式确认
od -t x1c -N 10 script.ksh
删除这些字符,它现在将以魔术#!
开头#!
。 您可能能够做到的一种方法是
sed -i -e '1s/^[^#]*//' script.ksh
首先在不使用-i
选项的情况下对其进行测试(您可以将其通过管道传输到od
以检查结果)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.