delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-10.2 required=5.0 tests=AWL,BAYES_00,KHOP_PGP_SIGNED,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <4FE23FDE.9070506@redhat.com> |
Date: | Wed, 20 Jun 2012 15:25:50 -0600 |
From: | Eric Blake <eblake AT redhat DOT com> |
User-Agent: | Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: piping input to executable reading from /dev/tty? |
References: | <4FE1FB4F DOT 3020808 AT kempt DOT net> <4FE1FD33 DOT 3070009 AT redhat DOT com> <4FE23EB0 DOT 2020406 AT kempt DOT net> |
In-Reply-To: | <4FE23EB0.2020406@kempt.net> |
OpenPGP: | url=http://people.redhat.com/eblake/eblake.gpg |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.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 |
--------------enig96F5D8FDB9D14810173620F2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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. >=20 > 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'. --=20 Eric Blake eblake AT redhat DOT com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig96F5D8FDB9D14810173620F2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJP4j/eAAoJEKeha0olJ0NqUYAIAIGmTkLp/s7d5xOxznZe6DI9 84YS7+cTNjhq28w13ylBj5Sr/DGXk9XT/qLQwu28dZxqRMYEhh+dqTg8zJWG8AFZ YE7vDOxsklqMI+UTmykhflfCmik+nTkLe0SHdp5W+f8vhSFSxtCE13RJ/o2LKLLU /7MmfALY6hR6gatqGF7ILINqsPef/tnbUbfniuqw8xPkT/0syqKxTAUNwUqiLJ37 jYTFEPVVgiwNg6DdtMoYnLc4/pcmkPpzuRbgYlIRRxNn59zaiQzUa55lYu/6YfC1 EHQ64LPHJmpfjoh803BWpCdQyXv6+czrb3cj3biXqQFX8lFkXTKz3lhyVpiLpmM= =wTDo -----END PGP SIGNATURE----- --------------enig96F5D8FDB9D14810173620F2--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |