This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Running `.com' and `.bat' files in bash?


george hawkins writes:
 > 
 > Hi there,
 > 
 > When I try to run a `.com' file from the bash prompt it fails like so:
 > 
 > > bash$ /WINNT/system32/edit.com
 > > /WINNT/system32/edit.com: /WINNT/system32/edit.com: cannot execute binary file
 > 
 > Also when I try to run a `.bat' file it fails (for entirely different
 > reasons I presume) - I think because bash is treating it as a script
 > file and forks off a shell to interpret it resulting in lots of
 > complaints about non-understood NT command prompt builtins.
 > 
 > In fact it was my difficulty running `.bat' files, that I first
 > tried to run a `.com' file. I was wondering if `command.com' was
 > the equivalent of a unix shell to which I could pass the `.bat'
 > file for it to interpret.  (Sorry if I'm completely wrong there,
 > I've always worked on UNIX systems and never had very much interest
 > in PCs until my new job now).
 > 
 > I hope this isn't a really stupid question, have I set things up
 > wrong? The fact that these must be problems most people face at
 > some time or another if this is usual behavior and yet they don't
 > appear to be referenced in either the FAQ or the mail archives
 > suggests to me that I must be missing something.

To run a .bat file from sh, you need to include something like

cmd /c foo

in the place where you want to run foo.bat. But beware, sh does not
pass the environment correctly to cmd (see earlier discussion) so you
may get some unexpected results, particularly when trying to unset
environment variables.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]