/bin/bash: cannot execute binary file

Greetings,
I think a similar question has been asked before, but I couldn't find the answer I need.
I'm trying to run a .exe file from matlab as
system('./file.exe')
But I got this error
/bin/bash: ./file.exe: cannot execute binary file
I hope someone could help, I'd really appreciate it.
thanks
ps:
file /bin/bash /bin/bash: Mach-O 64-bit executable x86_64

1 Comment

Carl - what can you tell us about the executable? What does it do? Have you tried including the full path to this executable? What happens when you try to run this from the command line (through a terminal window outside of MATLAB)?

Sign in to comment.

Answers (1)

Mach-O 64-bit executable x86_64 are used by OS-X, iOS, and some other operating systems derived from the MACH kernel. The only one of those that runs MATLAB these days is OS-X. However, OS-X does not use the .exe file extension, which hints you might be trying to execute the file on the wrong machine.
However, it is true that on Unix derivatives, the file extension is not the important feature for determining whether a file can be executed from the command shell by direct reference the way you show using ./file.exe . Instead what is required first is that the file have its execute permissions set as far as the user is concerned. If the execute bits are not set then you would receive a "Permission denied" message.
With the execute bits set, the operating system would look at the "magic number" to try to determine how the file should be executed. For text files, the "magic number" is "#!" as the first two characters of the file. For Mach-O 64 bit binaries that do not show up as "fat" binaries, the magic number involves in part the file starting with hex FE ED or hex CF FA. "file" indicates that those bytes are properly present in the file. If you were using OS-X and those bytes were not present then you would get an error message about trying to execute a binary file; likewise if you were using some other operating system and trying to execute mach-o files then you would get the same message. For example you would have a problem if you tried to execute such a file under Linux.
At this point we are stuck because we do not know which operating system you are running.

4 Comments

Thank you very much for your answer, I really appreciate it.
I'm trying to run the radiative transfer code MODTRAN (mod40r3.exe) on a OS-X El Capitan (version 10.11.5) machine. Following your advice, I'm doing:
> system('#!./mod40r3.exe')
In the same folder where the .exe file is located. Now I'm not getting the previous error (cannot execute binary file) and matlab gives a 0, but the model is not running, apparently, because the output files are not being created (tape files).
I'm still trying to figure out why I can't run the model. The input file (tape5) is correctly created, previously.
Thanks a lot
system('#!./mod40r3.exe') is a request to execute a comment...
Did you do the compiling and installation yourself as shown in pdf page 96 at <ftp://ftp.pmodwrc.ch/pub/Vorlesung%20K+S/MOD4_user_guide.pdf> ? If so then which fortran compiler did you use?
If you go to the shell command prompt (Applications -> Utilities -> Terminal in OS-X) then are you able to execute
./mod40r3.exe
?
Simon Lind
Simon Lind on 17 Aug 2016
Edited: Simon Lind on 17 Aug 2016
Thanks
Yes I got those files from a previous installation I did (DATA folder etc), perhaps I should try re installing on my new El Capitan machine.
Anyway, running the exe directly from a terminal gives the same answer (cannot execute binary file)
Thank you
I would suggest recompiling, yes.
You might also be having difficulties with a library not being on the DYLD_LIBRARY_PATH at the time you execute, but the message would typically be different than that.

Sign in to comment.

Categories

Asked:

on 13 Aug 2016

Commented:

on 17 Aug 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!