[英]Exec format error. Binary file not executable
I'm under 我在
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
trying to run a basic executable script.ksh file with permission 775 and containing: 尝试运行具有权限775且包含以下内容的基本可执行脚本script.ksh文件:
#!/bin/ksh
echo "hello ya"
but I have: 但我有:
$./script.ksh
./script.ksh: Exec format error. Binary file not executable.
the problem looks like to come from the shebang but I can't figure out why and how. 问题看起来像是来自shebang,但我不知道原因和方式。 I can run the script by doing this (note the weird output for the first line): 我可以这样做来运行脚本(注意第一行的输出很奇怪):
$ ksh script.ksh
script.ksh[1]: ?o?;??#!/bin/ksh: not found [No such file or directory]
hello ya
some (maybe) useful output: 一些(也许)有用的输出:
$ file script.ksh
script.ksh: Korn shell script, UTF-8 Unicode (with BOM) text executable
$ which ksh
/bin/ksh
do you have an idea? 你有想法吗?
ok the problem come from the option 好的,问题出在选项上
set bomb
in the .vimrc config file of vim. 在vim的.vimrc配置文件中。 Comment this line solve the problem. 评论此行解决问题。
The first line begins with some invisible characters, as shown in your error message: 第一行以一些不可见的字符开头,如错误消息中所示:
?o?;??#!/bin/ksh
: not found?o?;??#!/bin/ksh
:找不到
You can confirm this with 您可以通过以下方式确认
od -t x1c -N 10 script.ksh
Remove those characters, and it will now begin with the magic #!
删除这些字符,它现在将以魔术#!
开头#!
. 。 One way you might be able to do that is 您可能能够做到的一种方法是
sed -i -e '1s/^[^#]*//' script.ksh
Test it first without the -i
option (you can pipe it into od
to check the result). 首先在不使用-i
选项的情况下对其进行测试(您可以将其通过管道传输到od
以检查结果)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.