I want to pipe the output of ps -ef to python line by line.
The script I am using is this (first.py) -
#! /usr/bin/python
import sys
Another approach is to use the input() function (the code is for Python 3).
while True:
try:
line = input()
print('The line is:"%s"' % line)
except EOFError:
# no more information
break
The difference between the answer and the answer got by Dr. Jan-Philip Gehrcke is that now each of the lines is without a newline (\n) at the end.