all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Noam Postavsky <npostavs@gmail.com>
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 14:15:42 +0200	[thread overview]
Message-ID: <20190701121542.GT11749@protected.rcdrun.com> (raw)
In-Reply-To: <CAM-tV--+=2hT_PgaY_QzbfzQAr4y3yR2ZzHPZ3N0d517UR849g@mail.gmail.com>

* 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



  reply	other threads:[~2019-07-01 12:15 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 [this message]
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

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=20190701121542.GT11749@protected.rcdrun.com \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=npostavs@gmail.com \
    /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.