Subject: Running `.com' and `.bat' files in bash?
From: [email-masked] (Jon Thackray)

17 Apr 1997 03:39:21 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
References: <[email-masked]>
Original-To: cygnus <[email-masked]>
In-Reply-To: <[email-masked]>
Original-Sender: [email-masked]

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
"[email-masked]" with one line of text: "help".