简体   繁体   中英

standard in must be a tty Python script removing Sudo

I am trying to run the command

"sudo service awslogs start" 

from a python script. I cannot use 'sudo' so I change the command to

"su -c 'service awslogs start'"

but that does not seem to work either. I still get the error

su: user if=/dev/null does not exist

or

standard in must be a tty

Any ideas as to how to fix this?

sudo -S reads from stdin, see man sudo :

 -S, --stdin
     Write the prompt to the standard error and read the password from the
     standard input instead of using the terminal device.  The password must be
     followed by a newline character.

You can also change /etc/sudoer to allow your user to run the specific command without sudo.

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