X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org MIME-Version: 1.0 In-Reply-To: <4FE23FDE.9070506@redhat.com> References: <4FE1FB4F DOT 3020808 AT kempt DOT net> <4FE1FD33 DOT 3070009 AT redhat DOT com> <4FE23EB0 DOT 2020406 AT kempt DOT net> <4FE23FDE DOT 9070506 AT redhat DOT com> Date: Thu, 21 Jun 2012 07:34:52 -0400 Message-ID: Subject: Re: piping input to executable reading from /dev/tty? From: Earnie Boyd To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id q5LBZDbW030931 On Wed, Jun 20, 2012 at 5:25 PM, Eric Blake wrote: > On 06/20/2012 03:20 PM, Dan B. wrote: >> Eric Blake wrote: >>> On 06/20/2012 10:33 AM, Dan B. wrote: >>>> Is there any way to redirect /dev/tty similarly to how stdin can be >>>> redirected (e.g., like "echo ... | someexecutable")? >>> >>> Yes; use 'expect'. >>> >>>> Does Cygwin (or Unix/Linux, for that matter) have any equivalent way >>>> of redirecting /dev/tty? >>>> >>>> Can /dev/tty be redirected at all?  (I would guess that something >>>> could be done with pseudoterminals, but I know very little about >>>> them.) >>> >>> Yes, 'expect' is the command line tool that lets you script around >>> programs that expect to be run interactively, but where you want to >>> script the input that your program will see. >> >> Does expect use only redirection of file descriptors, or can it also >> redirect references to /dev/tty? > > expect uses pseudoterminals so that the stdin of the child process is > also its /dev/tty (remember, /dev/tty is a magic name that resolves to > the current controlling terminal, and that a pseutoterminal can be a > controlling terminal).  Therefore, anything that normally requires you > to interactively type something because the child process opened > /dev/tty can be run under expect, where opening /dev/tty in the child > will now be asking expect for the input, and expect then hands it the > information that you wrote into your expect script.  This is not > cygwin-specific, so you may get better support by looking for help on > using 'expect'. A word of caution, do not expect expect to function properly to a native (non-Cygwin) process. The PTY emulation cannot support it. -- Earnie -- https://sites.google.com/site/earnieboyd -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple