From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alex Kost Newsgroups: gmane.lisp.guile.user Subject: Re: How to do "ls /tmp > /dev/null" in Guile? Date: Mon, 21 Mar 2016 12:40:43 +0300 Message-ID: <8737rkcgo4.fsf@gmail.com> References: <87zituzs6d.fsf@gmail.com> <87zitulohf.fsf@elektro.pacujo.net> <87bn691rec.fsf@gmail.com> <87egb58pui.fsf@elektro.pacujo.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1458553252 25289 80.91.229.3 (21 Mar 2016 09:40:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Mar 2016 09:40:52 +0000 (UTC) Cc: guile-user@gnu.org To: Marko Rauhamaa Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Mar 21 10:40:42 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ahwKF-0002AG-Q9 for guile-user@m.gmane.org; Mon, 21 Mar 2016 10:40:40 +0100 Original-Received: from localhost ([::1]:56524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahwKF-0005m7-AQ for guile-user@m.gmane.org; Mon, 21 Mar 2016 05:40:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahwJy-0005m2-Kg for guile-user@gnu.org; Mon, 21 Mar 2016 05:40:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahwJt-0000lh-HP for guile-user@gnu.org; Mon, 21 Mar 2016 05:40:22 -0400 Original-Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]:36462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahwJt-0000lY-9M for guile-user@gnu.org; Mon, 21 Mar 2016 05:40:17 -0400 Original-Received: by mail-lf0-x22f.google.com with SMTP id d82so57705637lfe.3 for ; Mon, 21 Mar 2016 02:40:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=a8tk47ay+lDONKkmPULd21iHp9pNgWarzGVSlukSDl8=; b=y7xt4+4HkDdhjAsAiWdx6lYMdgyNDP7EC+C/sxGKsGqutHBaJeBcMvFKlNTqfxd607 H8Sy8urAjYdGijmbYd9AWTWRU8N1sWVVBe/zr/YtM7H0ZU2kGFn/VDcZF/O84W4oJdkd nrpvXNRuvH0IhSgkhH6SROJgl+XcSXENfholDIxVC+rB/KdjdNSLD8lYlzk6O68vyk2k sFpjkADfHAa5RBt8UxEEKMqRk2cYHaHBG3HzTzwPSF0hOhbJTTaMT6/zyWos+473074y aFd7CUOajzaWt3zXbQ0Tnnfln7R7ih+Q1VXETIocMKc43utKGGMiJTsGQkPNh5Vah1nz nyZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=a8tk47ay+lDONKkmPULd21iHp9pNgWarzGVSlukSDl8=; b=Rs2DtbXHrFnu2tIzVNvbvsrzcB+NnrRpEG4eYxgjmASFthG81eHo49fcOfZ4/YrZQf VAzyRqail9zyNY27fiiOWfsprng3vySb5mzwvIVFpqpgMgdvwJ3uhAhHdw47fH6SIl/l DeDZJ7L9JacPb6Ura5dY0IsaWLTFS3fWfUvMnr/VJhJVKHFEVVLUc+NX3ueB3uECNemC zhPdQ4bvFiIIdKTI1xgOL+ZEfHqXDrmbHSi0AmmTeqVvOFIvbGc98cGxxPe6Go/tk98M CBzoADFDxpxlSIC67z3D56dq9THFoZ3pyA2nTte22h6uVXKj2ZRdlGhZS22ZAdRf9il9 8a2g== X-Gm-Message-State: AD7BkJJRDaNxCnhFMKNXTjYRDbgiNMYBzSPVQ7tMMFABAu8EQ0NXd1bXQSWO2SlZbBLdzQ== X-Received: by 10.25.154.193 with SMTP id c184mr5648269lfe.69.1458553216304; Mon, 21 Mar 2016 02:40:16 -0700 (PDT) Original-Received: from leviafan ([217.107.192.146]) by smtp.gmail.com with ESMTPSA id e82sm4384081lfi.38.2016.03.21.02.40.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Mar 2016 02:40:15 -0700 (PDT) In-Reply-To: <87egb58pui.fsf@elektro.pacujo.net> (Marko Rauhamaa's message of "Sun, 20 Mar 2016 11:23:49 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22f 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:12495 Archived-At: Marko Rauhamaa (2016-03-20 12:23 +0300) wrote: > Alex Kost : > >> Ah, thanks! I get it. But I also want to check an exit status of the >> running command (sorry, that I didn't mention it). So I would like to >> have the following procedure: >> >> (define (system-no-output* . args) >> "Like 'system*' but suppress the output of the command indicated by ARGS." >> ???) >> >> Or even better (it would be a perfect solution for me) the following macro: >> >> (define-syntax-rule (with-no-process-output body ...) >> "Run BODY and suppress all output of the executed sub-processes." >> ???) > > Replace (close-input-port) with (close-pipe); that should give you the > exit status. Also you don't need to copy the data to a dummy port if you > only want to ignore it. (close-pipe) is what I needed, thanks! For the record here is the procedure: (define (system-no-output* . args) "Like 'system*' but suppress the output of the command indicated by ARGS." (let ((port (apply open-pipe* OPEN_READ args))) (read-string port) (close-pipe port))) >> and there would be no standard/error output from both "ls" calls. Is >> it possible? > > The diagnostic output (stderr) is a different story. You want to be sure > to want to ignore it. To implement that properly, you should go > lower-level with operating system calls (fork, exec, waitpid). Simply > open "/dev/null" for writing and dup the file descriptor into the slots > 1 and 2 of the child process. Thanks for the info! There are things to think about. -- Alex