delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <4FE1FB4F.3020808@kempt.net> |
Date: | Wed, 20 Jun 2012 12:33:19 -0400 |
From: | "Dan B." <danb AT kempt DOT net> |
User-Agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.19) Gecko/20081204 SeaMonkey/1.1.14 |
MIME-Version: | 1.0 |
To: | Cygwin-L <cygwin AT cygwin DOT com> |
Subject: | piping input to executable reading from /dev/tty? |
Received-SPF: | Pass (sender authenticated); receiver=punctilious.kempt.net; client-ip=173.79.157.238; envelope-from=<danb AT kempt DOT net> |
Received-SPF: | Pass (sender authenticated); receiver=punctilious.kempt.net; client-ip=173.79.157.238; helo=[192.168.1.11] |
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 |
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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |