简体   繁体   中英

subprocess not working properly for this sudo /etc/init.d/windscribe-cli start

Running without any error. But not starting the process... :(

    windscribe = subprocess.Popen(["echo", "<my pc password>", "|", "sudo", "/etc/init.d/windscribe-cli", "start"], stdout=subprocess.DEVNULL

Per default sudo doesn't read from stdin, but from the terminal-device. So your echo sends it output into a pipe that is never read, while the sudo waits for output from the tty, which doesn't receive any input. Use

sudo -S

or

sudo --stdin

to read from stdin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM