This is the mail archive of the cygwin 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]
Other format: [Raw text]

RE: Does anyone know how to invoke a bash process via a dos batch program so commands after bash execute?


> -----Original Message-----
> From: cygwin-owner On Behalf Of Lipin, Adam
> Sent: 13 April 2004 15:44

> The problem isn't calling bash. I can call bash without a problem. The
> problem is that I call bash then it executes bash and gives 
> me a prompt
> and then stops. It does not run any commands after executing bash.
> Whether I run bash.bat or bash.exe.

  In fact, that's exactly what you'd expect, come to think of it.  When
cmd.exe processes a command in a batch file, it doesn't redirect the
contents of the batch file into the stdin for that command.  It executes the
command program and waits for it to complete before reading more of the
batch file.  You wouldn't expect this to work, would you:

-----wont_work.bat-----
notepad.exe
Hello, this will NOT end up as text in the notepad document
-----wont_work.bat-----

  cmd.exe doesn't understand that bash.exe is a command shell, it just
treats it like any other program that's called from a batch file, and in
particular it doesn't pipe any input to it, from the batch file or anywhere
else.

  To get the effect you want, you should really put the bash commands into a
separate file and then use "bash -s < filename" (or even "cat filename |
bash -s" I suppose).  If you want to keep things localized in the one file,
you could use echo instructions to build a temporary script file.  It's a
shame that cmd.exe doesn't support here docs.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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