[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: |
Mon, 1 Jul 2019 14:15:42 +0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
* Noam Postavsky <npostavs@gmail.com> [2019-07-01 13:13]:
> On Mon, 1 Jul 2019 at 05:45, Jean Louis <bugs@gnu.support> 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
- 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, 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 <=
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, 2019/07/04