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: Thu, 4 Jul 2019 22:38:33 +0200 [thread overview]
Message-ID: <20190704203833.GL8543@protected.rcdrun.com> (raw)
In-Reply-To: <87v9wha9vk.fsf@mbork.pl>
This is version that I am using now.
(defun command-stream (command string &rest args)
"Feeds string as input to command"
(with-temp-buffer
(let* ((process (apply 'start-process "PROCESS" (current-buffer) command args)))
(set-process-sentinel process #'ignore)
(process-send-string process string)
(process-send-eof process)
(process-send-eof process)
(while (accept-process-output process))
(buffer-string))))
(defun markdown (string)
"This is for discount markdown"
(command-stream "markdown" string))
(markdown "## Hello")
(defun pandoc-markdown (string)
(command-stream "pandoc" string "-f" "markdown" "-t" "html"))
(pandoc-markdown "## Hello")
(defun proj/convert-arc1960-to-wgs84 (latitude longitude)
(let ((string (format "%s %s\n" latitude longitude)))
(command-stream "cs2cs" string "-f" "%.5f" "Arc 1960" "WGS84")))
(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)
I call it command-stream, probably is wrong.
Jean
prev parent reply other threads:[~2019-07-04 20:38 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
2019-07-04 19:16 ` Marcin Borkowski
2019-07-04 20:33 ` Jean Louis
2019-07-04 20:38 ` Jean Louis [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190704203833.GL8543@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).