When using the !
shortcut to execute shell commands from a Notebook, how can I respond to subsequent prompts?
For example: !read varname
Seems to hang the kernel indefinitely and I can't run another command to respond.
Anticipating the prompt in one cell like this doesn't work either:
!read varname
!my_answer
!echo $varname
The cell hangs with [*]
(these are simplified examples, the actual use case needs to respond to a 'y/n' prompt)
-y
or-n
option explicitly in the command. – Tannenwald-y
option works for my use case, which is uninstalling a package:!pip uninstall openpyxl -y
. I'll leave this question open since this is not a solution to the question as posted. – Sweatboxpip
should be used in conjunction with the magic symbol and not an exclamation point. See my comment here below how the magic version ofpip
was added in 2019 to overcome shortcomings that can arise with usingpip
with an exclamation point. – Essie