I'm attempting to execute Cygwin commands on Windows from a Java application. In cygwin's bin, I noticed some files are Application type (.exe) while others (like zcat and zless) have no extension and are just File type.
I've added the bin to the Windows PATH and seem to only be able to execute the .exe files from cmd. The code below works.
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "ls");
Process p = pb.start();
I want to use things like zcat and zless but they aren't executable and cmd complains that 'zcat' is not recognized as an internal or external command, operable program or batch file.
If I manually change the file to .exe, I get a pop-up error saying zcat can't start or run due to incompatibility with 64-bit versions of Windows. I've installed the 64-bit version of cygwin (setup-x86_64). Why isn't all of cygwin's bin executable?
Most of the cygwin programs are NOT binary program but script one.
The command file
can give you a description of the file type:
$ file zcat
zcat: POSIX shell script, ASCII text executable
while
$ file cat
cat: PE32+ executable (console) x86-64, for MS Windows
reading the first 5 rows of zcat
$ head -n 5 zcat
#!/bin/sh
# Uncompress files to standard output.
# Copyright (C) 2007, 2010-2016 Free Software Foundation, Inc.
we see on first row the #!
that says that is a script to be executed by the
/bin/sh
interpreter.
In other case we can have
$ head -n5 2to3
#!/usr/bin/python2.7.exe
import sys
from lib2to3.main import main
sys.exit(main("lib2to3.fixes"))
so 2to3
is a python 2.7 script