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: piping input to executable reading from /dev/tty?


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


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