Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60311

Re: Using sh library with grep command

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
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; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:command': 0.09; 'grep': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:library': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'obviously': 0.18; 'trying': 0.19; 'command': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'header:X -Complaints-To:1': 0.27; "i'm": 0.30; 'code': 0.31; "skip:' 10": 0.31; 'accidentally': 0.31; 'run': 0.32; 'url:python': 0.33; 'running': 0.33; 'actual': 0.34; 'maybe': 0.34; 'subject:with': 0.35; 'but': 0.35; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'reported': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'manually': 0.60; 'sample': 0.67; 'abc': 0.84; 'subject:Using': 0.84; '***': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Using sh library with grep command
Date Sat, 23 Nov 2013 17:29:36 +0100
Organization None
References <CAGfGq=ax9rHaiVYuKmkF4b8fTN_VyXznyzkoHq4FHcJ_W6BhOQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084ac13.dip0.t-ipconnect.de
User-Agent KNode/4.7.3
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.3092.1385224149.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385224149 news.xs4all.nl 15867 [2001:888:2000:d::a6]:59655
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60311

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Using sh library with grep command Peter Otten <__peter__@web.de> - 2013-11-23 17:29 +0100

csiph-web