Using sh library with grep command

Luca lucafbb at gmail.com
Sat Nov 23 09:38:17 EST 2013


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/



More information about the Python-list mailing list