Running an .exe file in cygwin.

0

I'm absolutely new in CYGWIN and Bash in total, so, I guess that there is an answer somewhere in a documentation, but I'm not succeeded finding it.

I have two files coexisting in a directory: file and file.exe. If I call file (using CYGWIN terminal), it gives me an error "cannot execute binary file: Exec format error" (because it accesses the file), but if I call file.exe, it works well. I've found in the manual that "the shell script has precedence and is selected for execution of file", but it seemes that it is wrong in my situation. So, what should I do to excecute file.exe calling file in terminal? Thanks in advance.

p.s. ./file also doesn't work; ./file.exe works well

Megabrukman

Posted 2018-11-12T15:03:39.827

Reputation: 1

Answers

1

Cygwin follows the Linux rules, where there are no default extensions for executable files. Such files are defined as executable by modifying their attributes using the chmod command, not by their extension.

You should not call the files by the same name, as "file" does not invoke "file.exe".

harrymc

Posted 2018-11-12T15:03:39.827

Reputation: 306 093

Thank you for your answer! Yes, I tried to change its attribute by chmod +x file.exe but nothing has changed. =( – Megabrukman – 2018-11-12T16:34:32.933

1The problem is the presence of file. Setting the attributes of "file.exe" won't help. Cygwin will not launch "file.exe" unless you execute "file.exe". It will execute "file" if you type "file". – harrymc – 2018-11-12T19:28:26.307

0

Rename the file to something else. This should be enough

mv file file2

The .exe so called magic handler inside cygwin will then treat file.exe and file as synonym.
Please also note that file is also a command of a base package

$ which file
/usr/bin/file
$ cygcheck -f $(which file)
file-5.32-1

and it is not a good idea to have a duplicate program name

matzeri

Posted 2018-11-12T15:03:39.827

Reputation: 1 662