subprocess.Popen and replacing the shell pipe line
I need to chain together three linux commands and get the final output. I read
the documentation for Popen in the subprocess module for replacing the shell
pipe line. I followed the example and keep getting a 0 where I should be
getting a 1.
I am trying to do this:
grep "Sep 22" /var/log/auth.log | grep "Illegal user" | wc -l
which returns a 1 when I run this manually.
This is what I did with python:
p1 = Popen(['grep', '"Sep 22"', '/var/log/auth.log'], stdout=PIPE)
p2 = Popen(['grep', '"Illegal user"'], stdin=p1.stdout, stdout=PIPE)
p3 = Popen(['wc', '-l'], stdin=p2.stdout, stdout=PIPE)
which always prints a 0. What am I doing wrong?
|All times are GMT. The time now is 09:22 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.