From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marko Rauhamaa Newsgroups: gmane.lisp.guile.user Subject: Re: How to do "ls /tmp > /dev/null" in Guile? Date: Sun, 20 Mar 2016 11:23:49 +0200 Message-ID: <87egb58pui.fsf@elektro.pacujo.net> References: <87zituzs6d.fsf@gmail.com> <87zitulohf.fsf@elektro.pacujo.net> <87bn691rec.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1458465846 11833 80.91.229.3 (20 Mar 2016 09:24:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Mar 2016 09:24:06 +0000 (UTC) Cc: guile-user@gnu.org To: Alex Kost Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Mar 20 10:24:05 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 1ahZad-0003eI-Bi for guile-user@m.gmane.org; Sun, 20 Mar 2016 10:24:03 +0100 Original-Received: from localhost ([::1]:52099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahZac-0005l8-OQ for guile-user@m.gmane.org; Sun, 20 Mar 2016 05:24:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahZaT-0005kz-Cq for guile-user@gnu.org; Sun, 20 Mar 2016 05:23:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahZaS-0000rv-8Y for guile-user@gnu.org; Sun, 20 Mar 2016 05:23:53 -0400 Original-Received: from [2001:1bc8:1a0:5384:7a2b:cbff:fe9f:e508] (port=36416 helo=pacujo.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahZaS-0000rl-0Q for guile-user@gnu.org; Sun, 20 Mar 2016 05:23:52 -0400 Original-Received: from elektro.pacujo.net (192.168.1.200) by elektro.pacujo.net; Sun, 20 Mar 2016 11:23:49 +0200 Original-Received: by elektro.pacujo.net (sSMTP sendmail emulation); Sun, 20 Mar 2016 11:23:49 +0200 In-Reply-To: <87bn691rec.fsf@gmail.com> (Alex Kost's message of "Sun, 20 Mar 2016 11:32:11 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:1bc8:1a0:5384:7a2b:cbff:fe9f:e508 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:12491 Archived-At: 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. > 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. Marko