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 11:24:00 +0200 Organization: START YOUR OWN GOLD MINE Message-ID: <20190701092400.GF11749@protected.rcdrun.com> References: <20190630223205.GA19895@protected.rcdrun.com> <875zomw7cf.fsf@mbork.pl> <20190701081716.GA11749@protected.rcdrun.com> <874l46w26t.fsf@mbork.pl> 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="165536"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: GNU Emacs Help To: Marcin Borkowski Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 01 11:24:49 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 1hhsYK-000gvt-KJ for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Jul 2019 11:24:48 +0200 Original-Received: from localhost ([::1]:56376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhsYG-0007Mm-7P for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Jul 2019 05:24:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48012) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhsXd-0007Jj-Sp for help-gnu-emacs@gnu.org; Mon, 01 Jul 2019 05:24:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hhsXc-0001yY-CR for help-gnu-emacs@gnu.org; Mon, 01 Jul 2019 05:24:05 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:57491) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hhsXc-0001x9-4p for help-gnu-emacs@gnu.org; Mon, 01 Jul 2019 05:24:04 -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 02:24:01 -0700 id 0000000000020357.000000005D19D131.00007514 Original-Received: from localhost (protected.rcdrun.com [local]) by protected.rcdrun.com (OpenSMTPD) with ESMTPA id cbfdcc90; Mon, 1 Jul 2019 09:24:00 +0000 (UTC) Content-Disposition: inline In-Reply-To: <874l46w26t.fsf@mbork.pl> 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:121084 Archived-At: * Marcin Borkowski [2019-07-01 11:14]: > I'm not sure I get it. > > If you have your data in _files_, why don't you > > (shell-command-to-string "cat | ...") > > ? The data is not in files, it is in the database. My Website Revision System is producing static HTML pages. Those updates to multiple websites have thousands and thousands of pages, and if I would be creating files for each invocation, that would shorten the life time of a hard disk and make it slower. And such easy invokation of shell command with some input is useful for various other utilities, for example conversion of coordinates, like here. (defun proj/arc1960-wgs84 (latitude longitude &optional time height) "Converts single coordinates in DD format from ARC1960 to WGS84 with default height, see https://github.com/OSGeo/proj.4/issues/1110 and https://earth-info.nga.mil/GandG/coordsys/onlinedatum/CountryAfricaTable.html" (let* ((lat-lon (proj/convert-arc1960-to-wgs84 latitude longitude)) (lat-lon (string-trim lat-lon)) (lat-lon (split-string lat-lon)) (latitude (first lat-lon)) (longitude (second lat-lon)) (height (third lat-lon))) (list latitude longitude height))) ;; original point -1.47666 34.56861 ;; geotrans point -1.47927 34.56933 ;; (proj/arc1960-wgs84 -1.47666 34.56861) (defun proj/convert-arc1960-to-wgs84 (latitude longitude) (let ((string (format "%s %s\n" latitude longitude))) (command-stream-in-out "cs2cs" string "-f" "%.5f" "Arc 1960" "WGS84"))) ;; (proj/arc1960-wgs84 -1.47666 34.56861) With result being ("-1.47926" "34.56938" "0.00000") Imagine having thousands of geographic locations in the database that require conversion, then for each would be created one file on hard disk. Until I learn how to use process-send-string, I am using memory files in /run/user/$UID Jean