[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to run shell command with stream input, to get string output
From: |
Jean Louis |
Subject: |
Re: How to run shell command with stream input, to get string output |
Date: |
Thu, 4 Jul 2019 22:38:33 +0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
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
- Re: How to run shell command with stream input, to get string output, (continued)
- Re: How to run shell command with stream input, to get string output, tomas, 2019/07/01
- Re: How to run shell command with stream input, to get string output, Jean Louis, 2019/07/01
- Re: How to run shell command with stream input, to get string output, Robert Pluim, 2019/07/01
- Re: How to run shell command with stream input, to get string output, Jean Louis, 2019/07/01
- Re: How to run shell command with stream input, to get string output, Noam Postavsky, 2019/07/01
- Re: How to run shell command with stream input, to get string output, Jean Louis, 2019/07/01
- Re: How to run shell command with stream input, to get string output, Marcin Borkowski, 2019/07/01
- Re: How to run shell command with stream input, to get string output, Jean Louis, 2019/07/01
- Re: How to run shell command with stream input, to get string output, Marcin Borkowski, 2019/07/04
- Re: How to run shell command with stream input, to get string output, Jean Louis, 2019/07/04
- Re: How to run shell command with stream input, to get string output,
Jean Louis <=