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