Get subprocess error output from shell command

Chris Rebert clp2 at rebertia.com
Sun Apr 3 06:14:25 CEST 2011


<quote what="earlier relevant post" reason="context">
On Sat, Apr 2, 2011 at 8:50 PM, Gnarlodious <gnarlodious at gmail.com> wrote:
> I get it, you instantiate an object, call a method and get a tuple in
> response. However, here is what I see:
>
>>>> process.communicate()
> (b'~/Library/Preferences/iCab/iCab 4 Bookmarks: Permission denied\n',
> b'')
>
> So all I get is the string and no error message,
</quote>

On Sat, Apr 2, 2011 at 9:00 PM, Gnarlodious <gnarlodious at gmail.com> wrote:
> On Apr 2, 9:29 pm, Chris Rebert wrote:
>
>> if proc.returncode: # non-zero exit status, indicating error
>>     print("Encountered error:")
>>     print(error_output) # output the error message
>>
>
> Like in my previous post, this only outputs an empty string.
> Apparently plutil doesn't communicate well.

Yes, it seems to output its error message to stdout, rather than
stderr in line with *nix conventions as one would expect.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list