I'm making a script and my app.py looks like this;
import subprocess
subprocess.call(["sudo", "apt-get", "update"])
subprocess.call(["sudo", "apt-get", "upgrade"])
And you might already know that this apt-gets are asking for a confirmation. I know I can put an extra -y
at the end but I need to know how to make it so it presses enter when prompted.
There are several prompts that doesn't accept -y
so that's why I'm asking.
For example; adding a repository or this screen when you run apt-get upgrade on Ubuntu 18.04
So I need to press Enter
automatically for these prompts. Which should be something like in this concept;
import subprocess
subprocess.call(["sudo", "apt-get", "update"])
(PRESS ENTER HERE WHEN PROMPTED)
subprocess.call(["sudo", "apt-get", "upgrade"])
(PRESS ENTER HERE WHEN PROMPTED WHICH ASKS YOU ABOUT 3 TIMES)