all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Marcin Borkowski <mbork@mbork.pl>
Cc: GNU Emacs Help <help-gnu-emacs@gnu.org>
Subject: Re: How to run shell command with stream input, to get string output
Date: Mon, 1 Jul 2019 11:24:00 +0200	[thread overview]
Message-ID: <20190701092400.GF11749@protected.rcdrun.com> (raw)
In-Reply-To: <874l46w26t.fsf@mbork.pl>

* Marcin Borkowski <mbork@mbork.pl> [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 <filename> | ...")
> 
> ?

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



  reply	other threads:[~2019-07-01  9:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-30 22:32 How to run shell command with stream input, to get string output Jean Louis
2019-07-01  7:18 ` Marcin Borkowski
2019-07-01  8:17   ` Jean Louis
2019-07-01  8:38     ` tomas
2019-07-01  9:06       ` Jean Louis
2019-07-01  9:38         ` Robert Pluim
2019-07-01  9:43           ` Jean Louis
2019-07-01 11:12             ` Noam Postavsky
2019-07-01 12:15               ` Jean Louis
2019-07-01  9:10     ` Marcin Borkowski
2019-07-01  9:24       ` Jean Louis [this message]
2019-07-04 19:16         ` Marcin Borkowski
2019-07-04 20:33           ` Jean Louis
2019-07-04 20:38           ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190701092400.GF11749@protected.rcdrun.com \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mbork@mbork.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.