Reputation: 17707
The specific problem I'm trying to solve is
telnet
sessionmessage
But the general problem is sending a command to an inferior (comint) process and waiting for output to come back and a new prompt to appear, and return the output.
I have:
(defun dired-vlc-test ()
(interactive)
(let* ((buf (process-buffer dired-vlc-telnet-proc))
(old-max (with-current-buffer buf
(point-max))))
(telnet-simple-send dired-vlc-telnet-proc "get_time")
(accept-process-output dired-vlc-telnet-proc 5)
(message (buffer-substring-no-properties old-max (with-current-buffer buf
(point-max))))))
However the output I always get is "get_time", i.e. Emacs is not waiting for new output.
I got the accept-process-output
idea from this question
Upvotes: 2
Views: 820
Reputation: 28541
accept-process-output
returns too early in your case because it returns as soon as it has accepted some output, but in your case you want to keep accepting output until you get a new prompt. Notice that the remote process does not tell Emacs "here's a prompt", so you will have to tweak your process filter to recognize "Oh, we received something that looks like a prompt" and you will have to call accept-process-output
in a loop until the process filter tells it (via some global variable, probably) that it has seen a prompt.
Upvotes: 3