0

For example, take a simple program

from subprocess import check_output
t = check_output(['ls', '-a'])
print t

now there are many commands which needs to be run with sudo permission. for given example

from subprocess import check_output
t = check_output(['sudo', 'ls', '-a'])
print t

but it asks for password in my terminal. instead I want to input the password programatically, even bypass this, if possible.

Nancy
  • 997
  • 1
  • 8
  • 12
  • You're going to need to use `pexpect`, not `subprocess` for this, because sudo doesn't read from stdin, instead, it interacts directly with the terminal. See the question I linked to in the comment above. – dano Aug 11 '14 at 17:26
  • You can bypass password security through entries in [`/etc/sudoers`](https://help.ubuntu.com/community/Sudoers). – Robᵩ Aug 11 '14 at 17:28

0 Answers0