【问题标题】:standard in must be a tty Python script removing Sudo标准输入必须是删除 Sudo 的 tty Python 脚本
【发布时间】:2016-06-08 14:59:50
【问题描述】:

我正在尝试运行命令

"sudo service awslogs start" 

来自 python 脚本。我不能使用“sudo”,所以我将命令更改为

"su -c 'service awslogs start'"

但这似乎也不起作用。我仍然收到错误

su: 用户 if=/dev/null 不存在

标准输入必须是 tty

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

【问题讨论】:

标签: python bash amazon-web-services scripting sudo


【解决方案1】:

sudo -S 从标准输入读取,见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 的情况下运行特定命令。

【讨论】:

    猜你喜欢
    • 2012-12-16
    • 2020-10-28
    • 2021-03-30
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多