4

Let's say I have a text file and grep "@" file.txt returns:

(1) preparing corpus @ Tue Apr 28 20:19:31 CEST 2015
(1.0) selecting factors @ Tue Apr 28 20:19:31 CEST 2015
(1.2) creating vcb file /media/2tb/ccexp/phrase-mkcls-mgiza-10clusters/work.en-ru/training/corpus/en.vcb @ Tue Apr 28 20:19:31 CEST 2015

And I want to use my python script that reads that output using something like:

grep "@" file.txt | python process.py

I've tried this (process.py but it only reads the first line:

import sys
logfile = raw_input()
print raw_input()

[out]:

(1) preparing corpus @ Tue Apr 28 20:19:31 CEST 2015

How do I read all the lines piped into the python script?

alvas
  • 115,346
  • 109
  • 446
  • 738

1 Answers1

0

As @AshwiniChaudhary suggested:

import sys
log = "".join([i for i in sys.stdin])
print log
alvas
  • 115,346
  • 109
  • 446
  • 738