Emacs by default allocates a pty for subprocesses. There’s no way to do this portably, as many Lisps don’t support it, so UIOP won’t help you here. If you’re on SBCL and portability is not a concern, you can use sb-ext:run-program with a :pty keyword argument, as described in section 7.7.3 of the SBCL manual. Failing that, it’s probably best to use sudo -S.
phoebe > On Jan 12, 2021, at 10:01 AM, Pierre Neidhardt <m...@ambrevar.xyz> wrote: > > Hi! > > I'd like to run a "sudo" command from Common Lisp. The following works: > > --8<---------------cut here---------------start------------->8--- > (uiop:launch-program '("sudo" "-S" "ls" "/root") :input :stream :output > *standard-output*) > (format (uiop:process-info-input #v1) "MY-PASSWORD~%") > (finish-output (uiop:process-info-input #v1)) > --8<---------------cut here---------------end--------------->8--- > > Note that I'm using the "-S" parameter of sudo. From the man page: > >> Write the prompt to the standard error and read the password >> from the standard input instead of using the terminal device. > > Without it, "sudo" terminate immediately. > > Somehow, Emacs _does_ support calling the sudo process without the "-S" > flag. Try this: > > --8<---------------cut here---------------start------------->8--- > (make-process :name "dummy" :command '("sudo" "ls" "/root")) > --8<---------------cut here---------------end--------------->8--- > > and the "sudo" process is kindly waiting for input in the background. > > Any idea why that is? > Is it be possible to do the same in Common Lisp? > > Cheers! > > -- > Pierre Neidhardt > https://ambrevar.xyz/
signature.asc
Description: Message signed with OpenPGP