I have an external command line program that I would like to invoke from elisp. This is easy enough with shell-command, but it doesn’t work correctly when the command line program is interactive, which in my particular case it is: The invoked script sees EOF when it reads stdin when I call it like this:
;; upload command is a string with the name of
;; a python script and some args
(shell-command upload-command
(get-buffer-create "*upload output*")))))
The python script identified by upload-command may ask some yes/no questions and it may prompt for a password, for which I’d like masked input. Ideally, all of this interaction would occur within the minibuffer.
How can I arrange things so that my external interactive command interacts with the user via minibuffer when called via elisp?
The easiest way is to use either
make-comintormake-comint-in-buffer:This will runs the script in a buffer like a
shellbuffer, so it doesn’t fulfill the requirement of having all interaction happen in the minibuffer. It will, however, automatically read passwords in masked form from the minibuffer, provided the password prompt matchescomint-password-prompt-regexp.Note that
upload-commandin this example here needs to be the name of an executable file onexec-path. Any extra switches or other arguments to the script have to be passed as string arguments tomake-comint:See the Emacs documentation for more details.