python - Using subprocess and pkexec -
i'm trying use run command alongside pkexec, says no such file found.
process = subprocess.popen(["pkexec cat", "/dev/input/event4"], stdout=subprocess.pipe) line in iter(process.stdout.readline, ''): sys.stdout.write(line)
oserror: [errno 2] no such file or directory
however, path okay , file there.
you want use:
subprocess.popen(["pkexec", "cat", "/dev/input/event4"])
since subprocess.popen
quotes each entry in list; example same using on commandline:
$ "pkexec cat" /dev/input/event4
instead of:
$ pkexec cat /dev/input/event4
from the documentation (emphasis mine):
args required calls , should string, or sequence of program arguments. providing sequence of arguments preferred, allows module take care of required escaping , quoting of arguments (e.g. permit spaces in file names). if passing single string, either shell must true (see below) or else string must name program executed without specifying arguments.
Comments
Post a Comment