Fix Binary Not Executing with Path in Bash

bashfreebsdosx-snow-leopard

I'm getting some weird behaviour for a binary file I'm trying to run. I'm using Mac OSX snow leopard, and the binary itself is part of labkey software .. built from source.

If I try to run the file using an absolute path it won't work .. failing with an error like

-bash /Users/me/Sources/labkey/build/bin/program: cannot execute binary file

However if I change to the directory /Users/me/Sources/labkey/build/bin/program and run the binary just by typing its name it works fine.

I've explored a number of permutations on executing the file.

From within the directory /Users/me/Sources/labkey/external/osx/bin/program if I attempt to run using

./program

I get the error above, but if I use

program

I don't get an error.

Any ideas on what could be going wrong?

Thanks for the answers just adding more info;
Output of file ./program is;

./Program: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.4, not stripped

Output of "which program" is;

Users/me/Sources/labkey/build/bin/program

Best Answer

You could have another installation of the file you are trying to run. When you run it without the "./" it could be calling it from somewhere else on your system (as it's in your PATH).

Do a "which program" to see if you are indeed calling the right file.