bash_kernel
bash_kernel copied to clipboard
Can't use sudo
I really love the concept of this. I see how productivity would improve by being able to document shell scripts, and tinker with them at the same time. However, I noticed that sudo won't work because it requires special input, I guess.
Yup, in general commands that require input don't work. There's a mismatch between the way Jupyter 'thinks about' input (something has to ask for a line of input), and the way terminals do it (you can send input at any time, and it's up to a program when it reads it).
Someone just suggested a possible idea to bridge those two models; it's not clear yet how practical it is: https://github.com/pexpect/pexpect/issues/557
Do you know if it's possible to set the bash to run as a certain user, and just give that user non-password access? I'm doing some system maintenance, and was hoping to document my adventures in a notebook.
You could run the entire notebook server as a particular user (we don't recommend running it as root, but it's possible if you want to take that risk). Other than that, you'd have to hack bash_kernel to start bash as a different user. Here's where it launches bash:
https://github.com/takluyver/bash_kernel/blob/0966dc102d7549f5c909c93de633a95b2af9f707/bash_kernel/kernel.py#L94-L96
This would be really useful for installations, just download the notebook and run the commands, documentation included. If only sudo worked. As it stands, one would have to go through the extra step of downloading the file as a script, and running it as superuser, if trusted. Not the end of the world for one person, but it adds up spread out across humanity ever.