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


Groups > comp.lang.python > #60305

Using sh library with grep command

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'url:pypi': 0.03; 'output': 0.05; 'exception,': 0.09; 'exit': 0.09; 'expected.': 0.09; 'subject:command': 0.09; 'url:blog': 0.10; 'grep': 0.16; 'subject:library': 0.16; 'obviously': 0.18; 'trying': 0.19; 'command': 0.22; 'import': 0.22; 'error': 0.23; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; "skip:' 10": 0.31; 'twitter:': 0.31; 'run': 0.32; 'url:python': 0.33; 'running': 0.33; 'blog:': 0.33; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:org': 0.36; 'to:addr :python-list': 0.38; 'reported': 0.39; 'to:addr:python.org': 0.39; 'manually': 0.60; 'url:it': 0.60; 'abc': 0.84; 'subject:Using': 0.84; '***': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=eywEMmkEQRnneotqy0yFRqr6tZ7fN6DNkGWOQnQM5R0=; b=tMygIi0BxDU3x5rn6KglUQYuG3Q74D540f67g5oKGI15JtchnS1aTtBWY/nXobFqBN SH3FbJkc7k0TUyz4CHZ21rHS62jitwCus+zwt4EOxeSiMqKRv2sGKUdsQlbTUKhJqbL8 4jNfqZaHw8I5BkNahpf2hXOf6wh9Cq+wREUplIyUIfkD1WXrgdpB3W28c9ZhIa3Aeu2N XfoeEEuJbqz64XauCdWR10miu4fHUJ17A78UwF/YXWD2Bm7y9MFnOIEkSjgEmGCHSHBy Pkqakz3pd04W02A7MF01uT5YAJh3blBDxROtlJpXCvJTE0O0Q57r5WOZJM0peCDqcte+ enLQ==
X-Received by 10.182.102.7 with SMTP id fk7mr16091480obb.28.1385217517464; Sat, 23 Nov 2013 06:38:37 -0800 (PST)
MIME-Version 1.0
From Luca <lucafbb@gmail.com>
Date Sat, 23 Nov 2013 15:38:17 +0100
Subject Using sh library with grep command
To "Python-list (General)" <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
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.3088.1385218947.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385218947 news.xs4all.nl 15926 [2001:888:2000:d::a6]:35193
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60305

Show key headers only | View raw


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?

-- 
-- luca

twitter: http://twitter.com/keul
linkedin: http://linkedin.com/in/lucafbb
blog: http://blog.keul.it/

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


Thread

Using sh library with grep command Luca <lucafbb@gmail.com> - 2013-11-23 15:38 +0100
  Re: Using sh library with grep command Roy Smith <roy@panix.com> - 2013-11-23 10:30 -0500

csiph-web