2

The specific problem I'm trying to solve is

  1. send a command to a running telnet session
  2. echo the result of the command with message

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

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Since I have to use process filter anyway, I just did the whole thing as one. Thanks for the hint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.