Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60316
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <lucafbb@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'url:pypi': 0.03; 'output': 0.05; 'exception,': 0.09; 'exit': 0.09; 'expected.': 0.09; 'skip:/ 10': 0.09; 'subject:command': 0.09; 'url:blog': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; '(both': 0.16; '23,': 0.16; 'grep': 0.16; 'subject:library': 0.16; 'to:addr:web.de': 0.16; 'exception': 0.16; 'sat,': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'obviously': 0.18; 'all,': 0.19; 'trying': 0.19; 'seems': 0.21; 'command': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'example.': 0.24; 'cc:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; "skip:' 10": 0.31; 'twitter:': 0.31; 'accidentally': 0.31; 'run': 0.32; 'url:python': 0.33; 'running': 0.33; 'blog:': 0.33; 'actual': 0.34; 'maybe': 0.34; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'url:org': 0.36; 'positive': 0.37; 'wrong': 0.37; 'so,': 0.37; 'expected': 0.38; 'nov': 0.38; 'pm,': 0.38; 'bad': 0.39; 'reported': 0.39; 'manually': 0.60; 'url:it': 0.60; 'first': 0.61; 'sample': 0.67; 'abc': 0.84; 'execution.': 0.84; 'glance': 0.84; 'otten': 0.84; 'subject:Using': 0.84; 'this...': 0.84; '***': 0.95; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=VZ2xsIOdcEHIrjhBkpmFkewqygHEZxSU+OnsVR3GuAE=; b=qWHKAo6CyLaHh9GDZS4DGsspfCjvQbwSQMXXlvCi9tEciUoRqxd0JpCYHiS/UjL1re n4594uMR13savpOzUff/9Ve9+SlJj2OrBq2IBzrtcG5TuJI1xTt6mUKnpBSAQmmo8woT Y0FqQ6BrnJcH92kPnHMWOGKY0DY8bNQITdM7Yf13E1kAI5xjcy2GbEcU9m8vuvbHujip 4tr71W9JFofzvh/wX+4xmRzELEc9Bhu2sWHW83OaxL4OHH1jyB+9NQnYw5o7xShvgf/X 8KbukUFD6/K5wLa8eAd+pITUUa3I0X3ND95JP6VsWKq+kRlYr02z0uagIV9cCvH616eV fsWQ== |
| X-Received | by 10.60.144.230 with SMTP id sp6mr16495661oeb.29.1385227412690; Sat, 23 Nov 2013 09:23:32 -0800 (PST) |
| MIME-Version | 1.0 |
| Sender | lucafbb@gmail.com |
| In-Reply-To | <l6ql3s$fkc$1@ger.gmane.org> |
| References | <CAGfGq=ax9rHaiVYuKmkF4b8fTN_VyXznyzkoHq4FHcJ_W6BhOQ@mail.gmail.com> <l6ql3s$fkc$1@ger.gmane.org> |
| From | Luca Fabbri <luca@keul.it> |
| Date | Sat, 23 Nov 2013 18:23:12 +0100 |
| X-Google-Sender-Auth | xD5KkAVpQj9qzBjhOER01M1UZ8A |
| Subject | Re: Using sh library with grep command |
| To | Peter Otten <__peter__@web.de> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | "Python-list \(General\)" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3097.1385227421.18130.python-list@python.org> (permalink) |
| Lines | 59 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1385227421 news.xs4all.nl 15905 [2001:888:2000:d::a6]:49135 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:60316 |
Show key headers only | View raw
On Sat, Nov 23, 2013 at 5:29 PM, Peter Otten <__peter__@web.de> wrote:
> Luca wrote:
>
>> I'm trying to use sh (https://pypi.python.org/pypi/sh) for calling
>> system grep command but it's now working as expected.
>>
>> An example:
>>
>> import sh
>> sh.grep('abc', os.getcwd(), '-r')
>>
>> But I get the ErrorReturnCode_1: exception, that I learned is the
>> normal exit code for grep command when it not found any match.
>>
>> The error instance object reported that the command run is:
>>
>> *** ErrorReturnCode_1:
>> RAN: '/usr/bin/grep abc /Users/keul/test_sh'
>>
>> Obviously manually running the command I get some output and exit code 0.
>>
>> Where I'm wrong?
>
> Did you run grep with or without the -r option?
>
> The code sample and the error message don't match. Maybe you accidentally
> left out the -r in your actual code.
>
Sorry all, it was a stupid error and I provided a bad example.
I was running...
sh.grep('"abc"', os.getcwd(), '-r')
...and the output of the command inside the exception was exactly...
RAN: '/usr/bin/grep "abc" /Users/keul/test_sh -r'
So, at first glance it was ok (copying/pasting it in in the terminal
return exactly was I expected).
The error? The doublequote inclusion.
Using this...
sh.grep('abc', os.getcwd(), '-r')
...I get this output...
RAN: '/usr/bin/grep abc /Users/keul/test_sh -r'
But this time I get the expected result (both in terminal and python
env). So seems that when quoting you get a false positive right
command output but a wrong execution.
--
-- luca
twitter: http://twitter.com/keul
linkedin: http://linkedin.com/in/lucafbb
blog: http://blog.keul.it/
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Using sh library with grep command Luca Fabbri <luca@keul.it> - 2013-11-23 18:23 +0100
csiph-web