0

I'm under

Linux version 3.3.4-5.fc17.x86_64 ([email protected]) (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?

0

2 Answers 2

1

ok the problem come from the option

set bomb

in the .vimrc config file of vim. Comment this line solve the problem.

Sign up to request clarification or add additional context in comments.

Comments

1

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

2 Comments

indeed, that's what the option "bomb" does in vim: prepending a BOM mark to the file.
I thought so - but reasoned that the explanation might be more valuable than the fix, in case there are other editors that are broken in the same way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.