delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/05/07/15:23:22

X-Spam-Check-By: sourceware.org
Message-ID: <2284342f0605071223n30e8eafv9cc229653f4f1fa@mail.gmail.com>
Date: Sun, 7 May 2006 14:23:08 -0500
From: "Doug Bohl" <douglas DOT bohl AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Redirecting bash stdin
In-Reply-To: <44491A56.8030809@gmail.com>
MIME-Version: 1.0
References: <44491A56 DOT 8030809 AT gmail DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k47JNL5G030457

Hmmm... I'll take a look at your code if I get time, but here's an
inefficient (yet simple) solution that would at least work: You could
start Cygwin/bash in an invisible DOS prompt window, and send commands
to it by simulating keystrokes (PostMessage or SendMessage...
WM_KEYDOWN, WM_KEYUP).  Yeah, it's sloppy, but it would probably do
the trick.

On 4/21/06, Dave <kilroyd AT googlemail DOT com> wrote:
> I'm trying to get a mingw GUI application to pipe commands to cygwins
> bash by redirecting its stdin as described here
> <http://support.microsoft.com/?id=190351>.
>
> This nearly works.
>
> 1. Start app.
> 2. Spawn bash with redirected stdin. bash process visible in process
> explorer.
> 3. Send command1 to bash. No response.
> 4. Send command2 to bash. Response to command1 seen
> 5. Exit app. Response to command2 seen.
>
> Command1 and command2 start notepad with different files, so the
> response I'm expecting is a visible notepad window.
>
> I'm ensuring the commands are terminated with "&\n\0" and even tried
> "&\r\n\0" and "&\n\n\0".
>
> I'm flushing the write end of the stdin pipe with FlushFileBuffers.
>
> I've tried adding a 2nd WriteFile (just spaces and \n) to see if that
> flushes the buffer. It doesn't.
>
> The Microsoft documentation states that it is the responsibility of the
> child process (bash) to empty its stdin.
>
> I've tried a couple shells: ash and pdksh appear to work as expected.
> tcsh responds immediately but exits after the first command. zsh acts
> like bash.
>
> Does anyone know what I can do to get bash to respond promptly? Or will
> this approach not work with bash?
>
> If necessary I can put the code on the net somewhere.
>
> Thanks,
>
> Dave.
>
> Windows 2000 Professional Ver 5.0 Build 2195 Service Pack 4
>
> cygwin1.dll version 1.5.19
>
> GNU bash, version 3.00.16(14)-release (i686-pc-cygwin)
> Copyright (C) 2004 Free Software Foundation, Inc.
>
>
> PS If I can get it working, the above is intended for a revamped chere.
> So I need it to work with bash, since ash won't let me get a login shell
> and pdksh seems like an odd requirement.
>
> --
> 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/
>
>

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