On Sat, Apr 2, 2011 at 8:07 PM, Gnarlodious <gnarlodi...@gmail.com> wrote: > I'm running a shell command like: > plutil -convert xml1 "~/Library/Preferences/iCab/iCab 4 Bookmarks" > > Getting error: > ~/Library/Preferences/iCab/iCab 4 Bookmarks: Permission denied > > How would I capture this error using a method of subprocess? > > I read the doc at > http://docs.python.org/release/3.0.1/library/subprocess.html > > but confess I don't understand it.
from subprocess import Popen, PIPE target = '~/Library/Preferences/iCab/iCab 4 Bookmarks' args = ['plutil', '-convert', 'xml1', target] proc = Popen(args, stdout=PIPE, stderr=PIPE) output, error_output = proc.communicate() if proc.returncode: # non-zero exit status, indicating error print("Encountered error:") print(error_output) # output the error message Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list