Sadly I’m not sure what mpkg
is, but there are two options.
- Either it is a self-running package, perhaps a shell script, akin to the
.run
format sometimes used for Unix software. In this case, your invocation of Popen
is correct, as long as you have the execute permission on File.mpkg
(check with ls -l /Path/to/File.mpkg
). The installer should be running fine.
Or, it is intended to be processed by a system tool, like .deb
packages are handled with the dpkg
program. In this case, you need something like this:
p = subprocess.Popen(['/usr/bin/dpkg', '-i', '/Path/to/File.deb'], ...)
or, alternatively:
p = subprocess.Popen('dpkg -i /Path/to/File.deb', ..., shell=True)
Now, what you do with this Popen
object depends on what you want to achieve. If you wish to get the output of the process, you need to call Popen.communicate
, like this:
p = subprocess.Popen(
['/Path/to/File.mpkg'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
(out, err) = p.communicate()
Now out
contains the standard output and err
the standard error.
If you just want to invoke the command and wait until it completes, you can also use the subprocess.call
shortcut.