I am attempting to execute sudo from a python script:
import os
command = 'id'
os.popen("sudo -S %s"%(command), 'w').write('password')
My server is configured to not allow non-TTY shells to execute sudo for security reasons, is there a workaround for this to execute the sudo command using python (without using su).
The above code outputs:
sudo: sorry, you must have a tty to run sudo