0

Let me tell you my problem. I've a shell script which execute a Linux executable. I don't have access to the source code of this exe.

When I run the script on the Linux machine, there is no problem. But, if I try to run the script on my Windows laptop, using cygwin, I have the error "cannot execute binary file".

There is any solution ?

Thanks !

2
  • You need to tell us what the executable is. Commented Dec 22, 2015 at 15:49
  • informations extracted from command "file" : ELF 32-bit LSB executable for GNU/Linux 2.6.9 Commented Dec 22, 2015 at 15:52

3 Answers 3

3

From https://stackoverflow.com/a/4144536/5704102:

"... Cygwin is a compatibility layer, which aims to implement as much as possible of the POSIX and Linux APIs within Windows. This means that programs have to be compiled specifically for Cygwin ..."

0

What does this script look like? Is it a bash script? If so, you may want to try sh <scriptfile> in Cygwin. If this doesn't work, and it is a bash script, make sure you have sh.exe. Type sh and hit tab twice to check.

Another potential issue if it is a bash script is that you don't have something installed that Cygwin requires to run the script. Make sure all the commands the script is trying to run will work. If not, you may have to run the Cygwin installer and install whatever is needed to run the script.

Also, you may want to check permissions.

If the file has an exe extension, it SHOULD work on Windows unless it was compiled for 64 bit architecture and you're running a 32 bit OS. Otherwise, you could be missing some .dll files that the executable relies on.

Edit:

If this is the contents of your script:

echo START
/oper/file.exe

then it's likely you have the incorrect path. Cygwin paths typically start with /cygdrive/c/ in Windows. Go to where the file exists and type pwd to get the correct path, then modify your script accordingly.

20
  • Yeah it's a bash script. So i call the script with sh command, and i've tried with sh executable.exe to run it, but there is the same issue Commented Dec 22, 2015 at 16:12
  • The file has the exe extension? If it does, then it probably is not a bash script. If you open the file in a text editor what does it look like? Commented Dec 22, 2015 at 16:14
  • my script is a bash script. But this script try to run the executable with exe extension. Commented Dec 22, 2015 at 16:19
  • What executable? sh.exe? Could you edit your question to show me exactly what the command is you're trying to run and what the name of the file you're trying to run? Also, posting the contents of the file you're trying to run could be helpful. Commented Dec 22, 2015 at 16:24
  • Go to where that file exists, type pwd then edit the script to point to the correct path. Commented Dec 22, 2015 at 16:30
0

Content of Script.sh in oper folder :

echo START
/cygdrive/c/Users/jo/oper/file.exe

In Cygwin terminal (in the right folder):

sh Script.sh

(Path updated)

Not the answer you're looking for? Browse other questions tagged or ask your own question.