From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How to run shell command with stream input, to get string output Date: Mon, 1 Jul 2019 14:15:42 +0200 Organization: START YOUR OWN GOLD MINE Message-ID: <20190701121542.GT11749@protected.rcdrun.com> 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 Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="80370"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: GNU Emacs Help To: Noam Postavsky Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 01 14:17:12 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 1hhvF9-000Kq2-Oq for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Jul 2019 14:17:11 +0200 Original-Received: from localhost ([::1]:58090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhvF8-0001Im-OO for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Jul 2019 08:17:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54218) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhvDz-0001Hd-Fp for help-gnu-emacs@gnu.org; Mon, 01 Jul 2019 08:16:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hhvDs-0003xG-T1 for help-gnu-emacs@gnu.org; Mon, 01 Jul 2019 08:15:55 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:41643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hhvDq-0003rd-3T for help-gnu-emacs@gnu.org; Mon, 01 Jul 2019 08:15:51 -0400 Original-Received: from protected.rcdrun.com (localhost [::1]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA; Mon, 01 Jul 2019 05:15:43 -0700 id 000000000002035A.000000005D19F96F.0000016A Original-Received: from localhost (protected.rcdrun.com [local]) by protected.rcdrun.com (OpenSMTPD) with ESMTPA id 1925d36d; Mon, 1 Jul 2019 12:15:42 +0000 (UTC) Content-Disposition: inline In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.170.207.13 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:121088 Archived-At: * Noam Postavsky [2019-07-01 13:13]: > 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. > Excellent! Thank you. I see it can work as below, and even markdown needs two times EOF. (with-temp-buffer (let* ((process (make-process :name "NEW" :buffer (current-buffer) :command '("markdown") :sentinel #'ignore))) (process-send-string process "Hello\n============") (process-send-eof process) (process-send-eof process) (while (accept-process-output process)) (buffer-string))) Maybe process-send-eof is making sure of one blank line on the end, as this works without 2 EOF: (with-temp-buffer (let* ((process (make-process :name "NEW" :buffer (current-buffer) :command '("markdown") :sentinel #'ignore))) (process-send-string process "Hello\n============\n") (process-send-eof process) (while (accept-process-output process)) (buffer-string))) And this works too with proj software to convert coordinates, so I will use your example. (with-temp-buffer (let* ((process (start-process "NEW" (current-buffer) "cs2cs" "-f" "%.5f" "Arc 1960" "WGS84"))) (set-process-sentinel process #'ignore) (process-send-string process "-1.47666 34.56861") (process-send-eof process) (while (accept-process-output process)) (buffer-string))) Thank you, Jean