From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17256 invoked by alias); 20 Jun 2012 16:34:58 -0000 Received: (qmail 16758 invoked by uid 22791); 20 Jun 2012 16:34:56 -0000 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 Received: from punctilious.kempt.net (HELO punctilious.kempt.net) (208.72.84.196) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 Jun 2012 16:34:43 +0000 Received: from [192.168.1.11] (pool-173-79-157-238.washdc.fios.verizon.net [173.79.157.238]) (authenticated bits=0) by punctilious.kempt.net (8.14.4/8.14.4) with ESMTP id q5KGYapI025678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 20 Jun 2012 12:34:42 -0400 (EDT) Message-ID: <4FE1FB4F.3020808@kempt.net> Date: Wed, 20 Jun 2012 16:34:00 -0000 From: "Dan B." 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 Subject: piping input to executable reading from /dev/tty? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: Pass (sender authenticated); receiver=punctilious.kempt.net; client-ip=173.79.157.238; envelope-from= 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@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2012-06/txt/msg00372.txt.bz2 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