I'm trying to write a script which checks for prerequisite software in Ubuntu and if not installed, goes ahead and installs it.
I'm a newbie to Python and I understand that Python's subprocess module can be used to achieve this goal.
I have written this below sample code but not sure why it is failing.
import subprocess
c = subprocess.Popen(['sudo','apt-get','install','git'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
grep_stdout = c.communicate(input='root')[0]
print(grep_stdout)
When I run this program, i get the following error...
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts
Am i missing something here?