delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/13/11:04:17

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Dave Korn" <dk AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: Does anyone know how to invoke a bash process via a dos batch program so commands after bash execute?
Date: Tue, 13 Apr 2004 16:02:43 +0100
MIME-Version: 1.0
In-Reply-To: <E6292146029E2943934457D3F16DA44A405BB5@bkexch112.msdwis.com>
Message-ID: <NUTMEGb4BREm2k02Wfv0000043b@NUTMEG.CAM.ARTIMI.COM>
X-OriginalArrivalTime: 13 Apr 2004 15:02:44.0390 (UTC) FILETIME=[5FFC4460:01C42168]

> -----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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019