From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9195 invoked from network); 15 May 2008 14:51:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 15 May 2008 14:51:15 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 63384 invoked from network); 15 May 2008 14:51:09 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 May 2008 14:51:09 -0000 Received: (qmail 10796 invoked by alias); 15 May 2008 14:51:05 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25038 Received: (qmail 10780 invoked from network); 15 May 2008 14:51:04 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 15 May 2008 14:51:04 -0000 Received: from mail.o2.co.uk (sidious.london.02.net [82.132.130.152]) by bifrost.dotsrc.org (Postfix) with ESMTP id 789C08059114 for ; Thu, 15 May 2008 16:51:00 +0200 (CEST) Received: from sc.homeunix.net (78.105.216.138) by mail.o2.co.uk (8.0.013.3) (authenticated as stephane.chazelas) id 480CEB80050F016D; Thu, 15 May 2008 15:50:55 +0100 Received: from chazelas by sc.homeunix.net with local (Exim 4.69) (envelope-from ) id 1JwenH-0002Ox-0C; Thu, 15 May 2008 15:50:55 +0100 Date: Thu, 15 May 2008 15:50:54 +0100 From: Stephane Chazelas To: Peter Stephenson Cc: zsh-workers@sunsite.dk Subject: Re: zpty woes Message-ID: <20080515145054.GC5190@sc.homeunix.net> Mail-Followup-To: Peter Stephenson , zsh-workers@sunsite.dk References: <34AE8142-F5DA-44FD-96BA-61BDE12BC74E@mac.com> <200805151318.m4FDIvKS015244@news01.csr.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <200805151318.m4FDIvKS015244@news01.csr.com> User-Agent: Mutt/1.5.16 (2007-09-19) X-Virus-Scanned: ClamAV 0.91.2/7128/Thu May 15 12:45:41 2008 on bifrost X-Virus-Status: Clean On Thu, May 15, 2008 at 02:18:57PM +0100, Peter Stephenson wrote: > Jaime Vargas wrote: > > In the script attached, when trying to follwing line always fails. > > > > zpty -r scppty line "*:" || echo "no password asked" && exit > > > > It appears that the "password" string from the ssh session is discarded > > by the psuedo terminal. > > > > Is there a way to fix this? or Am I missing something? > > Yes and yes, but it's annoying and I spent a few minutes rediscovering > the arcana. zpty attempts to read in whole lines, while the password > prompt isn't a whole line. I came across this myself and looked at the > code a while ago and it seemed unnecessarily obscure. However, I worked > around it and don't have time to make it work sensibly in all the > possible cases, so I'm not touching it. (If anyone's interested it's in > ptyread() in Src/Modules/zpty.c and could definitely do with someone > taking it over; it's pretty much self-contained.) > > To work around this, you need to use non-blocking mode, i.e. start with > "zpty -b scppty ...". I think (although the code is obscure) that with > your "*:" pattern this will work, i.e. although it doesn't block it will > carry on reading until it gets the password input. If not, you would > need to delay (the zsh/zselect module allows you to do this in 100ths of > a second) and retry. (Waiting for a pattern with noblocking is > effectively a busy wait so even this isn't ideal---you can add the -t > option to the -r command line to test first, but then it *won't* wait > if there's no input and you do have to delay in your script.) [...] It works for me without "-b", why would you say "-b" is necessary? The problem I've found is that zpty -r doesn't return when the command in the pty has terminated. A strace -p shows: read(12, 0xb7ba04c8, 1) = -1 EIO (Input/output error) read(12, 0xb7ba04c8, 1) = -1 EIO (Input/output error) read(12, 0xb7ba04c8, 1) = -1 EIO (Input/output error) read(12, 0xb7ba04c8, 1) = -1 EIO (Input/output error) read(12, 0xb7ba04c8, 1) = -1 EIO (Input/output error) read(12, 0xb7ba04c8, 1) = -1 EIO (Input/output error) read(12, 0xb7ba04c8, 1) = -1 EIO (Input/output error) read(12, 0xb7ba04c8, 1) = -1 EIO (Input/output error) read(12, 0xb7ba04c8, 1) = -1 EIO (Input/output error) [...] And the other problem I mentionned in another email about the PS4 output not being correct. -- Stéphane