Created
January 8, 2020 12:04
-
-
Save pgp/d5e378b72015d8adb1926a0c572cd0be to your computer and use it in GitHub Desktop.
Programmatically use sudo from python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
sudoPassword = b'mySudoPassword\n' | |
cmd = 'sudo -S touch /dev/shm/1.txt'.split(' ') | |
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) | |
p.communicate(sudoPassword) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment