【问题标题】:Run terminal command within Tkinter script在 Tkinter 脚本中运行终端命令
【发布时间】:2013-10-11 16:16:37
【问题描述】:

我正在使用 tkinter。如何在我的代码中传递终端命令。更具体地说,我想运行“chmod +x test.py”命令。我试过 "os.system("chmod +x rec.py") 没有运气。谢谢。

【问题讨论】:

  • 你能描述一下“没有运气”是什么意思吗?您是否收到一条错误消息说“没有运气”?程序会崩溃吗?它似乎工作,但权限没有改变?你有堆栈跟踪吗?

标签: linux command-line terminal tkinter


【解决方案1】:
import os
os.chmod('/path/to/rec.py', stat.S_IRWXU)

add execute permission flag for the ownerrec.py。当然,运行脚本的用户必须是超级用户或rec.py的所有者才能更改执行权限标志。

【讨论】:

    【解决方案2】:

    这对我有用:

    os.chmod('rec.py',0755)
    

    【讨论】:

      猜你喜欢
      • 2021-10-24
      • 1970-01-01
      • 2018-09-01
      • 2018-05-04
      • 1970-01-01
      • 2016-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多