From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Hartwig Newsgroups: gmane.lisp.guile.user Subject: Re: Filter IO through an external command Date: Fri, 24 Feb 2012 11:31:40 +0800 Message-ID: References: <877gzdbhbr.fsf@gnuvola.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1330054313 11764 80.91.229.3 (24 Feb 2012 03:31:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 24 Feb 2012 03:31:53 +0000 (UTC) To: Thien-Thi Nguyen , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Feb 24 04:31:53 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S0lst-0007On-BI for guile-user@m.gmane.org; Fri, 24 Feb 2012 04:31:51 +0100 Original-Received: from localhost ([::1]:47268 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0lsq-0003dV-C5 for guile-user@m.gmane.org; Thu, 23 Feb 2012 22:31:48 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:40626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0lsm-0003dL-Sz for guile-user@gnu.org; Thu, 23 Feb 2012 22:31:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0lsk-0001yV-3R for guile-user@gnu.org; Thu, 23 Feb 2012 22:31:43 -0500 Original-Received: from mail-tul01m020-f169.google.com ([209.85.214.169]:60569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0lsj-0001yR-TF for guile-user@gnu.org; Thu, 23 Feb 2012 22:31:42 -0500 Original-Received: by obbta7 with SMTP id ta7so2761602obb.0 for ; Thu, 23 Feb 2012 19:31:41 -0800 (PST) Received-SPF: pass (google.com: domain of mandyke@gmail.com designates 10.50.156.225 as permitted sender) client-ip=10.50.156.225; Authentication-Results: mr.google.com; spf=pass (google.com: domain of mandyke@gmail.com designates 10.50.156.225 as permitted sender) smtp.mail=mandyke@gmail.com; dkim=pass header.i=mandyke@gmail.com Original-Received: from mr.google.com ([10.50.156.225]) by 10.50.156.225 with SMTP id wh1mr769491igb.0.1330054300936 (num_hops = 1); Thu, 23 Feb 2012 19:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=8VhXXj2fttmoYkKcizmhldzQVgbues0TPeA30xt4j+M=; b=M1GnZHXbvRO3zQTlfiSCBPobR4WgZNjYJadsaw7pwfZAurRGD+HxzURpxcKhh+v6+5 hHcRiXWb61Fhz0sYDnDzK16zKlYkHJ1A3ynHavFn7KA1xuToyxJggd0vL/WhAk2nDhq2 ItoRokezeEswTXvqf91Hc8OgWi0V58mTIXn10= Original-Received: by 10.50.156.225 with SMTP id wh1mr634798igb.0.1330054300892; Thu, 23 Feb 2012 19:31:40 -0800 (PST) Original-Received: by 10.231.24.7 with HTTP; Thu, 23 Feb 2012 19:31:40 -0800 (PST) In-Reply-To: <877gzdbhbr.fsf@gnuvola.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.169 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9303 Archived-At: On 24 February 2012 01:16, Thien-Thi Nguyen wrote: > () Tristan Colgate > () Thu, 23 Feb 2012 14:26:28 +0000 > > =C2=A0 I tried using open-input-output-pipe but hit issues. > > What were the issues? > Not sure if this is similar to the OP's issue=E2=80=A6 Some programs wait until their stdin is closed before producing any output--gzip is a good example. open-pipe is insufficient for this because (close-output-port pipe) closes both ends. This looks more like a limitation of soft-port than open-pipe: scheme@(guile-user)> (use-modules (ice-9 popen)) scheme@(guile-user)> (define pipe (open-pipe "gzip" OPEN_BOTH)) scheme@(guile-user)> (display "foo\n" pipe) scheme@(guile-user)> (force-output pipe) scheme@(guile-user)> (drain-input pipe) $7 =3D "" scheme@(guile-user)> (close-output-port pipe) scheme@(guile-user)> (drain-input pipe) ERROR: In procedure drain-input: ERROR: In procedure drain-input: Wrong type argument in position 1 (expecting open input port): # Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1]> ,q scheme@(guile-user)> (close-pipe pipe) $8 =3D 36096 I ended up using run-with-pipe from guile-lib's (os process) module which returns separate port objects--similar to the OP's proc..