【问题标题】:Enter sudo password through python通过python输入sudo密码
【发布时间】:2015-09-03 20:59:10
【问题描述】:

我正在制作一个不会在终端中运行的 python 脚本,因为它必须 sudo 多个脚本,我需要能够从脚本中输入密码。我的意思是:我编写的并且只有我要使用的程序启动。它使用一个 gui 框来询问我的sudo 密码。我把它给它,然后它在需要时进入它。我得到了文本框部分的下行路径,但是如何从 python 将密码输入到sudo 程序中?

【问题讨论】:

  • 我想你的意思是,你如何在python中使用sudo命令?

标签: python passwords sudo


【解决方案1】:

我在这里找到了答案:https://superuser.com/questions/67765/sudo-with-password-in-one-command-line

它是这样工作的:

$echo <password> | sudo -S <command>

【讨论】:

  • 请阅读here:Please note: Any method which involves putting your login password in plain text, in a command or in a file, is insecure and should NOT be used!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-27
  • 2017-11-24
  • 2019-09-04
相关资源
最近更新 更多