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]

piping input to executable reading from /dev/tty?


Is there any way to redirect /dev/tty similarly to how stdin can be
redirected (e.g., like "echo ... | someexecutable")?


I'm working with an executable (openssl in ocsp mode) that reads a password via /dev/tty (instead of stdin) because normally it wants to get that password from the user even if the user invoked the executable by running a script (and because it uses stdin for data input). (I can see the use of /dev/tty by using strace.)

However, I'm trying to invoke that executable from a script and have it
run non-interactively.  (It's an example/test script that should be
interactive and does not need to be secure.)

Other OpenSSL subcommands like "openssl ca" and "openssl req" have
command-line options for specifying passwords non-interactively.
However, the "openssl ocsp" subcommand does not, so I'm trying to find
some other way to suppress the interactive prompting for the password.


VMS's equivalent of /dev/tty was its environment variable SYS$COMMAND. SYS$COMMAND by default continued to refer to the interactive terminal even when SYS$INPUT (VMS's equivalent to the stdin descriptor) was redirected. Therefore, scripts could read from SYS$COMMAND when they wanted to read something that normally came from the user even when standard input was redirected.

However, a second script calling that first script could specifically
set SYS$COMMAND if it wanted to non-interactively provide that input
that the first script expected to normally come from the user.


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

If so, can it be done with existing commands used in a script (as
opposed to via lower-level programming)?  (Can pseudoterminals be
set up/created/whatever via existing commands, or only via library
calls?)

Thanks,
Daniel





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