中的标准必须是删除Sudo的tty Python脚本 [英] standard in must be a tty Python script removing Sudo

查看:61
本文介绍了中的标准必须是删除Sudo的tty Python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行命令

"sudo service awslogs start" 

来自python脚本.我无法使用'sudo',因此我将命令更改为

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:用户if =/dev/null不存在

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

标准中的必须是tty

standard in must be a tty

关于如何解决此问题的任何想法?

Any ideas as to how to fix this?

推荐答案

sudo -S 从stdin中读取,请参见 man sudo :

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.

您还可以更改/etc/sudoer ,以允许您的用户无需sudo即可运行特定命令.

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

这篇关于中的标准必须是删除Sudo的tty Python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆