3
How can I determine(in a python script or any other scripting environment) if a program that I have to call is a native windows executable or compiled with cygwin1.dll. I am inside the cygwin environment for this.
3
How can I determine(in a python script or any other scripting environment) if a program that I have to call is a native windows executable or compiled with cygwin1.dll. I am inside the cygwin environment for this.
3
If you are inside cygwin environment, you can use ldd
command, it will return the dependences of a executable, see:
$ ldd /bin/ls.exe ntdll.dll => /mnt/c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffd413d0000) KERNEL32.DLL => /mnt/c/WINDOWS/System32/KERNEL32.DLL (0x7ffd40af0000) KERNELBASE.dll => /mnt/c/WINDOWS/System32/KERNELBASE.dll (0x7ffd3e570000) cygintl-8.dll => /usr/bin/cygintl-8.dll (0x3e8b40000) cygwin1.dll => /usr/bin/cygwin1.dll (0x180040000) cygiconv-2.dll => /usr/bin/cygiconv-2.dll (0x3f2300000)
$ ldd c:/Windows/System32/control.exe ntdll.dll => /mnt/c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffd413d0000) KERNEL32.DLL => /mnt/c/WINDOWS/System32/KERNEL32.DLL (0x7ffd40af0000) KERNELBASE.dll => /mnt/c/WINDOWS/System32/KERNELBASE.dll (0x7ffd3e570000) ADVAPI32.dll => /mnt/c/WINDOWS/System32/ADVAPI32.dll (0x7ffd40d30000) msvcrt.dll => /mnt/c/WINDOWS/System32/msvcrt.dll (0x7ffd40520000) [...]
You can also execute following line:
ldd $PROGRAM | grep cygwin1.dll | wc -l
It will return 1 in case of $PROGRAM contains a dependence with cygwin1.dll
1
Use the 'cygpath' shell tool to find the FULL cygwin-style path of your executable. Then detect what that path begins with.
I have no cygwin to test this out; therefore no example.
1Matching 'cygpath -w /' at the beginning of 'cygpath -w executablepath' would work. – Ravi – 2017-11-13T04:00:31.050
Run it outside of the Cygwin environment if it works then it’s a windows executable – Ramhound – 2017-11-12T17:56:01.823