osx - What can I do about "cannot execute binary file"
2014-04
I have a little shell script that simply starts up a Java program. It is installed somewhere deep in the hierarchy, so I don't want to add its containing folder too my path. So I put a symbolic link into /usr/bin
. But when I try to run it, I get:
-bash: /usr/bin/asadmin: cannot execute binary file
I checked the permissions, and both the symbolic link and the shell script are executable. What can I do about this?
I have a little shell script that simply starts up a Java program.
Within your script, are you invoking the Java program directly? You need to use java --jar {java program name}
instead of just specifying the name of the Java program.
I can't believe I'm asking this...clearly I'm in rare form today.
Trying to setup a new Ubuntu machine and just downloaded 'p4' (Perforce command line client). It's a single file download - a statically-linked binary executable, so I just did:
wget http://www.perforce.com/downloads/perforce/r09.2/bin.linux26x86/p4
...right into /usr/bin. Simple enough. Except:
root@aj-ubuntu:/usr/bin# ll p4
-rwxr-xr-x 1 root root 748808 2010-02-11 16:54 p4
root@aj-ubuntu:/usr/bin# ./p4
-su: ./p4: No such file or directory
root@aj-ubuntu:/usr/bin# /usr/bin/p4
-su: /usr/bin/p4: No such file or directory
What in the world is happening here...?!
Thanks in advance for your ridicule :)
-aj
Ok, I got the file from your URL (its under 800KB) and tried this (from a Cygwin terminal which was handy).
$ file p4
p4: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped
But, you expect it to be statically linked, Why?
Update: Just to be sure, please confirm you are running a 32-bit Ubuntu.
If you are running a 64-bit system, you probably need the 'ia32-libs
' package.
try file ./p4
and see what it says. Chances are you don't have the right libraries installed to run it (so it cannot load the binary at all - you get the same issues with Windows if you don't have the right dlls)
Do ls -lb p4*
to see if there are any stray characters in the filename.
That's what happens when your executable isn't valid, it might be for another architecture or for another kernel. Or just a corrupted ELF header.
The intepreter readelf -a /usr/bin/p4 | grep interpreter
points to is probably missing. It's probably shipped in some compat package as pointed out by other commenters.
chmod +x /usr/bin/p4
static executable is not dependent of libraries.... it needc a compatible kernel, namely one that has same system calls as it was built on.
p4 is a perforce client, and yours is built against kernel v2.2.5 10 years ago...
it will work with (long unsupported) later 2.2 kernels,
it may work with (month since unsupported) 2.4 kernels,
it will not work with (still supported) 2.6 and 3.x kernels
They make version for 2.6 clients http://www.perforce.com/downloads/complete_list available for your needs.