From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Catonano Newsgroups: gmane.lisp.guile.user Subject: Re: capture stdout and stderr Date: Tue, 29 May 2018 19:35:27 +0200 Message-ID: References: <20180524.101022.981642295161978602.post@thomasdanckaert.be> <20180527.192654.1341019063623949776.post@thomasdanckaert.be> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1527615254 17505 195.159.176.226 (29 May 2018 17:34:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 29 May 2018 17:34:14 +0000 (UTC) Cc: Guile User To: Thomas Danckaert Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue May 29 19:34:10 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fNiVa-0004P3-AT for guile-user@m.gmane.org; Tue, 29 May 2018 19:34:06 +0200 Original-Received: from localhost ([::1]:34183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNiXh-00079R-Ca for guile-user@m.gmane.org; Tue, 29 May 2018 13:36:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNiWw-00077E-OC for guile-user@gnu.org; Tue, 29 May 2018 13:35:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNiWv-00046N-Gn for guile-user@gnu.org; Tue, 29 May 2018 13:35:30 -0400 Original-Received: from mail-yw0-x243.google.com ([2607:f8b0:4002:c05::243]:47096) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fNiWv-00045j-0h for guile-user@gnu.org; Tue, 29 May 2018 13:35:29 -0400 Original-Received: by mail-yw0-x243.google.com with SMTP id v197-v6so3770218ywc.13 for ; Tue, 29 May 2018 10:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=3PUymmBFSvVHRiX/7y8Y8t2GxxdpET0uYv8Ep3xaGwI=; b=aMryKLjNzpLCH6plsjDxtF3yfVTdjwy9tk1o3IqUFq18pbovA/UUEzVf9v3VwGDc+C 4q3Ykcw5dLvm11ZcU3De4QC7qRYqksLmc3VFZm4df0mQNBoeFbMWa7EkcNwz772UuTqe OYbspxLQyg8Xj9oXRmvJ4BvdjR3rAnGCOuTWmsy+QM26Z0shXvC1ViAx84SE+vj9eUvi p6sKJ6LE6KzxBbBklOUoT6D82i0cr2v+8F00Ob9rwTTTenr/cAYP9XD+Qkm3b9h8M7er yl3KmTR8pBQMsIzu3Eg+CMfw6so9/ts7pB0qHWAA65pPmFUWGTyEggRJnOlzGyxR4VCc 8Afw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=3PUymmBFSvVHRiX/7y8Y8t2GxxdpET0uYv8Ep3xaGwI=; b=QeYWwjLOyvwp5r78Y57StKzRQA2pfrhtE1MIutfug2UkUGyTEgWd0Ur48S/EHxpOMR gjMwgTaqksHZTs6ye1jgYt7ZvAu7uj9NSocJe8JSjdTBPt2H2LUJjHyk3+Z8jD3Jte7T JcAtIq3CJEwvfstE+8Td+6ad2F+4C0Q/2GqvrZBQI0OmV11n5rKZIvVAFJEV+jAL4v6r Q9moROErllDNM+huqof0Ijso2uro2eA+tjTXB9EMElmEpubKZCMh/beiFQpUmv0o7jnL GZu4Pgms84U6t81UNDt2PYMLsQCw1h8/JWQKWm6SPOUUmlOM/oT2LkwVysXMaCQjGAx+ s/Ow== X-Gm-Message-State: ALKqPweYAuXknKvF5KsJcnNEcpHYycU+mXLlDT3JRw8CQv9rLa7/kTT/ 2/5uJCqaPFeLsjVT11LkT52wFnW7cx6Ob1jU/w== X-Google-Smtp-Source: ADUXVKIL256qhlH0NEeUMENyN8xe346nPEBLnX/kaAxoACn4tUTgnrcgp0ASUYzG/bT5rc0YT6wDSiKCpx6GR7Lw46k= X-Received: by 2002:a0d:fac6:: with SMTP id k189-v6mr9581999ywf.262.1527615328128; Tue, 29 May 2018 10:35:28 -0700 (PDT) Original-Received: by 2002:a81:6dce:0:0:0:0:0 with HTTP; Tue, 29 May 2018 10:35:27 -0700 (PDT) In-Reply-To: <20180527.192654.1341019063623949776.post@thomasdanckaert.be> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4002:c05::243 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.lisp.guile.user:14587 Archived-At: 2018-05-27 19:26 GMT+02:00 Thomas Danckaert : > From: Stefan Israelsson Tampe > Subject: Re: capture stdout and stderr > Date: Thu, 24 May 2018 15:25:51 +0200 > > I think that your code whould work but doesn't because string ports are >> not file ports and system commands pipes out to file ports. >> >> 'open-input-pipe' uses 'scm_open_process' that returns only a read-port >> and a write-port, the write port is then taped the output string in your >> run-command. >> and it works. >> >> ALso when you create a err-port with pipe, you create a file port nad >> this will be used translated as an error port for the system comand and it >> all works. >> However the failing program uses a string port which is not a file port >> and it does not end up capturing the error output in the system command. >> >> One would wish that guile if the error port is not a file port make a >> file port, as done with 'pipe' and create a thread that pipes the data from >> the file port to the non file port and your code >> would work. Also similarly behavior for read and write ports towards the >> shell. >> >> the relevant code is in posix.c, scm_open_process >> > > Hi! Thanks for the message. Indeed, that makes sense. In fact I had some > vague intuition that some magic would be needed to channel the stderr > output into such a string port. I think the manual could be more explicit > about that, though? (e.g. in the section on default ports > https://www.gnu.org/software/guile/manual/html_node/Default- > Ports.html#Default-Ports ). Maybe I should propose a patch to the docs, > stating that those "with-x-to-port" methods only work on file ports. > > Thomas > > > Thomas thank you for sharing the solution