Strange grep behavior

14 views
Skip to first unread message

Bernstein, Gary

unread,
Mar 1, 2012, 9:46:52 AM3/1/12
to repo...@googlegroups.com
This morning I wanted to review all the products that were NOT deprecated. As far as I can tell, reposado doesn't have any way of doing it. So, I figured I would pipe the output to grep, but for some reason I get an error when I do that:

/usr/local/reposado/repoutil --products | grep -L Deprecated
Traceback (most recent call last):
  File "/usr/local/reposado/repoutil", line 587, in <module>
    main()
  File "/usr/local/reposado/repoutil", line 556, in main
    list_products(sort_order=options.sort, reverse_sort=options.reverse)
  File "/usr/local/reposado/repoutil", line 243, in list_products
    print_product_line(product['key'], products, catalog_branches)
  File "/usr/local/reposado/repoutil", line 180, in print_product_line
    deprecation_state)
  File "/usr/local/reposado/reposadolib/reposadocommon.py", line 173, in print_stdout
    sys.stdout.flush()
IOError: [Errno 32] Broken pipe


However the following command works just fine:

/usr/local/reposado/repoutil --products | grep Deprecated

Thoughts?

Thanks
-Gary

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 -- "The reward for work well done is the opportunity to do more."

 -- "I tried, but it didn't work" is a lot better than "I wish I'd tried."

        Gary R. Bernstein
Interim Assistant Director of FAA IT Services
College of Fine and Applied Arts
University of Illinois - Urbana-Champaign
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Greg Neagle

unread,
Mar 1, 2012, 9:52:28 AM3/1/12
to repo...@googlegroups.com
From man grep:

       -L, --files-without-match
              Suppress normal output; instead print the name of each input file from which no output would normally have been printed.  The scanning will stop on the first
              match.

You aren't passing a list of filenames to grep, so that flag is not appropriate. You want:

       -v, --invert-match
              Invert the sense of matching, to select non-matching lines.

Try:

/usr/local/reposado/repoutil --products | grep -v Deprecated

-Greg

Bernstein, Gary

unread,
Mar 1, 2012, 10:00:45 AM3/1/12
to repo...@googlegroups.com
Thanks.
I need more caffeine!

What surprised me was that it looked like repoutil was giving the error.

-Gary

Raul Cuza

unread,
Mar 1, 2012, 10:44:59 AM3/1/12
to repo...@googlegroups.com
It is! The pipe is broken when using the -L option, so the python
script errors out.
Reply all
Reply to author
Forward
0 new messages