简体   繁体   English

执行格式错误。 二进制文件不可执行

[英]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.

相关问题 32 位 linux 可执行文件失败并出现 Exec 格式错误。 二进制文件不可执行 - 32 bit linux executable failing with Exec format error. Binary file not executable sudo throw 错误无法执行二进制文件 exec 格式错误 - sudo throw error cannot execute binary file exec format error cygwin二进制exec格式错误 - cygwin binary exec format error -bash: ./radiobot 无法执行二进制文件:Exec 格式错误 - -bash: ./radiobot cannot execute binary file: Exec format error raspbian 上的 flyway 问题:无法执行二进制文件:执行格式错误 - Problem with flyway on raspbian: Cannot execute binary file: Exec format error ./abc.o: 无法执行二进制文件:Exec 格式错误 - ./abc.o: cannot execute binary file: Exec format error linux x86_64 vm gcc可执行输出的体系结构中的错误,exec文件格式错误 - linux x86_64 vm gcc error in architecture of executable output, exec file format error 无法执行二进制文件:在 WSL 环境中编译的二进制文件的 Exec 格式错误 - cannot execute binary file: Exec format error for a binary compiled in WSL environment 无法执行二进制文件:编译Linux内核后,Exec格式错误 - Cannot execute binary file: Exec format error after compiling Linux kernel 运行由g ++创建的二进制文件的“执行格式错误” - “Exec format error” running a binary created by g++
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM