0

Hi I start a python script by using python script.py.

But I need to write into a file which is inside the /usr/local/etc folder that requires permission of root. So I think I need to spawn a child process with sudo; the password to run the as sudo must be hardcoded into the script.

How do I do it?

2
  • Possible duplicate of stackoverflow.com/questions/22574201/… Commented Nov 23, 2017 at 11:51
  • You can configure sudo so it does not require a password. You can also require the python script be started by root (that is, by "sudo script.py) and then use the os.setresuid call to change privileges for the necessary parts of the program. Commented Jul 5, 2018 at 13:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.