[英]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. 从python脚本。 I cannot use 'sudo' so I change the command to
我无法使用“ sudo”,因此我将命令更改为
"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 su:用户if = / dev / null不存在
or 要么
standard in must be a tty 中的标准必须是tty
Any ideas as to how to fix this? 关于如何解决此问题的任何想法?
sudo -S
reads from stdin, see man sudo
: sudo -S
从stdin读取,请参见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. 您也可以更改
/etc/sudoer
以允许您的用户在不使用sudo的情况下运行特定命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.