I can run:
sudo service postgresql start
from the command line with no issues. However when I try running the following:
import os
from subprocess import Popen,PIPE
pwd = getsudopwd()
cmd = ['sudo','service',process,'state']
p = Popen(cmd,stdout=PIPE,stdin=PIPE,stderr=PIPE,universal_newlines=True)
out,err = p.communicate(pwd+'\n')
if err: raise RuntimeError(err)
I get the following error
chmod: changing permissions of '/var/run/postgresql': Operation not permitted. So, why is there is an error accessing the pid directory for postgresql when this is run from Python?