Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2489
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'args': 0.07; 'subprocess': 0.09; 'pm,': 0.11; 'output': 0.12; 'subject:error': 0.12; 'error:': 0.14; 'wrote:': 0.14; 'popen,': 0.16; 'proc': 0.16; 'subject:command': 0.16; 'subject:subprocess': 0.16; 'target]': 0.16; 'capture': 0.16; 'permission': 0.16; 'url:blog': 0.18; 'shell': 0.19; 'command': 0.19; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'cheers,': 0.20; 'header:In-Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; 'doc': 0.23; 'indicating': 0.23; 'received:209.85.214.174': 0.23; 'received:mail- iw0-f174.google.com': 0.23; "i'm": 0.26; 'chris': 0.27; 'message- id:@mail.gmail.com': 0.28; 'error': 0.29; 'sat,': 0.29; 'skip:" 30': 0.29; 'exit': 0.29; "skip:' 30": 0.29; 'cc:addr:python.org': 0.31; 'it.': 0.31; 'url:library': 0.31; 'import': 0.32; 'url:docs': 0.33; 'using': 0.34; 'like:': 0.35; 'status,': 0.35; 'running': 0.36; 'getting': 0.36; 'received:209.85': 0.37; 'url:python': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'url:org': 0.38; 'received:209.85.214': 0.39; 'received:209': 0.39; 'how': 0.39; 'would': 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'url:3': 0.68; 'url:0': 0.69; 'subject:Get': 0.74; 'skip:~ 30': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=n5+lY60BoXjgzbdi6SVhiIhvngF7QYuBP0o7e9dfrZ4=; b=ERAqyJVgbgDu80+ardhXakKItetwdUGX6cSg/Rjul/O0gd8Vq7IYVfVh8iKmgz2lBf 1dolIZGGFDWKgImGxupqMvGdaQ/O5pcYWvVGYWCrHfIwl0IVdYf+ZN856so1uEp2tInf P1kKNHHPIqjm/58+0PHErXTxlFylrMpIwvOwM= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=NUPV7rGMEESXwjj5zpb+tXFVnh0IvkQYc0ktftlu7YMKRePjAHXPrz94571WJvVN6j vKQa2OU4yfFvvdkIk10XHnSqwlDgzLSmFtkIq1MwTgXZuTOr/XZjC2t1cUmRbho2oU2R cT/ZUSpQP85K+IjcVxMuYZCkWrDjXcuMAnjwg= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <dc8e1dcd-303c-4e07-bdda-1b12277976f0@f31g2000pri.googlegroups.com> |
| References | <dc8e1dcd-303c-4e07-bdda-1b12277976f0@f31g2000pri.googlegroups.com> |
| Date | Sat, 2 Apr 2011 20:29:14 -0700 |
| X-Google-Sender-Auth | lnbVRbIcw_a-cmIGrbARlt5y5xI |
| Subject | Re: Get subprocess error output from shell command |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Gnarlodious <gnarlodious@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.150.1301801357.2990.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1301801358 news.xs4all.nl 81474 [::ffff:82.94.164.166]:34226 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:2489 |
Show key headers only | View raw
On Sat, Apr 2, 2011 at 8:07 PM, Gnarlodious <gnarlodious@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Get subprocess error output from shell command Gnarlodious <gnarlodious@gmail.com> - 2011-04-02 20:07 -0700
Re: Get subprocess error output from shell command Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-04-02 23:25 -0400
Re: Get subprocess error output from shell command Gnarlodious <gnarlodious@gmail.com> - 2011-04-02 20:36 -0700
Re: Get subprocess error output from shell command Chris Rebert <clp2@rebertia.com> - 2011-04-02 20:29 -0700
Re: Get subprocess error output from shell command Gnarlodious <gnarlodious@gmail.com> - 2011-04-02 20:50 -0700
Re: Get subprocess error output from shell command Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-04-03 00:03 -0400
Re: Get subprocess error output from shell command Chris Rebert <clp2@rebertia.com> - 2011-04-02 21:10 -0700
Re: Get subprocess error output from shell command Gnarlodious <gnarlodious@gmail.com> - 2011-04-02 21:00 -0700
Re: Get subprocess error output from shell command Chris Rebert <clp2@rebertia.com> - 2011-04-02 21:14 -0700
csiph-web