简体   繁体   中英

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:

#!/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. 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. 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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM