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


Groups > comp.lang.python > #60311

Re: Using sh library with grep command

From Peter Otten <__peter__@web.de>
Subject Re: Using sh library with grep command
Date 2013-11-23 17:29 +0100
Organization None
References <CAGfGq=ax9rHaiVYuKmkF4b8fTN_VyXznyzkoHq4FHcJ_W6BhOQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3092.1385224149.18130.python-list@python.org> (permalink)

Show all headers | 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