Run a linux system command as a superuser, using a python script

后端 未结 6 1850
野性不改
野性不改 2020-12-13 10:32

I have got postfix installed on my machine and I am updating virtual_alias on the fly programmatically(using python)(on some action). Once I update the entry in the /etc/pos

6条回答
  •  情书的邮戳
    2020-12-13 11:19

    import os
    os.popen("sudo -S /etc/init.d/postifx reload", 'w').write("yourpassword")
    

    This of course is almost always not a good idea as the password is in plain text.

提交回复
热议问题