From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.help Subject: Re: How to run shell command with stream input, to get string output Date: Mon, 1 Jul 2019 07:12:22 -0400 Message-ID: References: <20190630223205.GA19895@protected.rcdrun.com> <875zomw7cf.fsf@mbork.pl> <20190701081716.GA11749@protected.rcdrun.com> <20190701083833.GA25877@tuxteam.de> <20190701090623.GD11749@protected.rcdrun.com> <20190701094300.GG11749@protected.rcdrun.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="81358"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Robert Pluim , Help Gnu Emacs mailing list To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 01 13:13:26 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hhuFS-000L3K-Do for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Jul 2019 13:13:26 +0200 Original-Received: from localhost ([::1]:57184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhuFR-0003HF-BB for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Jul 2019 07:13:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42443) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhuEp-0003DP-6y for help-gnu-emacs@gnu.org; Mon, 01 Jul 2019 07:12:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hhuEn-0004QQ-35 for help-gnu-emacs@gnu.org; Mon, 01 Jul 2019 07:12:47 -0400 Original-Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]:41085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hhuEl-0004HQ-2H for help-gnu-emacs@gnu.org; Mon, 01 Jul 2019 07:12:43 -0400 Original-Received: by mail-ot1-x32a.google.com with SMTP id o101so12751882ota.8 for ; Mon, 01 Jul 2019 04:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/NZ2h+S1BIzL9glcGr1K7Ean/NY/o1DStcnPLZY2zmY=; b=POE69mucdzuXiQBJu37Jks6rryMiwT9agJCjArNrygMyfDnlHU+wmH16PS1qeyVaQh zQw5T3pnFSa0J16X/zQNp6LPbJN0M257+wc5pB+o5veBiKgW6PfNOZaWtMYj72/r1b5m 81aq47ecZ8LMnnkIjjT7r3pOJs0AXtbbujWI6n7fGf6dj28SEj+tcUFm4kmV7cSyZbLo SRVc2C5Fgf+1r/Xl0nhHLYgFuUbMPn7KM0XCVditXwmCwo44GwDyhiJjAeUI3bLx6qc4 McKc/6wnVNbJobn/Nv/mPtTnWjaoL7v9EnmUVKLsbiQ1OimJYQ4FVvtDJ3p7mqHnEiX1 2Ksw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/NZ2h+S1BIzL9glcGr1K7Ean/NY/o1DStcnPLZY2zmY=; b=WA38BFT9FvJRZHvfSx2YHGZjGYjc79cbaRrbz8jc5PZthA8cO9n665mrjfJytLJUsX BjS6TvLznGl+QO3/HlWF0O45JA8Nq9lfIoVU33nsBy2KkSDCcU7xgflxYFCKQbmOGoJ/ LPYFvSxKQpl+NyWmfzHPeW5h1rQE8jBRHDWLJ0C0wX5PMrzDW+BhL9DbLB0kiBLHANHo EhyEkGEJVRS81ByasMO2XRx0CPrUP4fFCTVuyyC+yrO/2etpjyH/VYs8QQB8/bSuSLt0 4vPpqoMj7ri1eQ2Z+y2rZaJvBRTOMzGrIslGRFhWpdCl8h4WPQDAIwIBEEUmPoMsz5Vr qNjA== X-Gm-Message-State: APjAAAW09phx1dfE+8kqZqKDUi5n+RcAIVqjo98CWkYcY04Vw+F6rC8+ 3EcdchxyuVPSItg3Oy0+kPsnz1NEre4vkceggQHoqcfb X-Google-Smtp-Source: APXvYqxwfcaEgcbbNxtwYuiPqoNHRKtUyzUBUreTUkLd+3sVOkFSYWc3rdsQG4UioMMgdxzrTSscqczz0r+O94GKuYo= X-Received: by 2002:a05:6830:1cd:: with SMTP id r13mr17619683ota.99.1561979558586; Mon, 01 Jul 2019 04:12:38 -0700 (PDT) In-Reply-To: <20190701094300.GG11749@protected.rcdrun.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::32a X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:121087 Archived-At: On Mon, 1 Jul 2019 at 05:45, Jean Louis wrote: > Something like that, but it does not work as > output of process is not written in the buffer. When input is not newline terminated, cat requires two EOFs. I find this is the case when running outside of Emacs as well. (with-temp-buffer (let* ((process (start-process "NEW" (current-buffer) "cat"))) ;; Don't include "Process NEW finished\n". (set-process-sentinel process #'ignore) (process-send-string process "Hello") (process-send-eof process) (process-send-eof process) (while (accept-process-output process)) (buffer-string))) But if you don't need asynchoronous input, call-process-region is simpler: (with-temp-buffer (insert "Hello") (call-process-region (point-min) (point-max) "tr" t '(t t) nil "a-z" "A-Z") (buffer-string))