Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to understand how piping works and am stuck at this point.

A log file is being streamed and its output is being piped to pigz. What I am trying to do is, redirect the pigz content to a python script as stdin.

I can't figure out how to redirect the data to script

This currently works:

./customread file_name | pigz -dc

This shows the log contents to stdout, how do I pipe it to the script from here?

I've tried

python < `./customread file_name | pigz -dc`

I want to redirect the data as it comes in..

share|improve this question
up vote 0 down vote accepted

Not being too familiar with what you're trying to get to, but I think you can just use another nested pipe. I've done similar in bash and zsh. With pigz outputting to stdout with -c, just pipe that to your python script looking for stdin.

./customread file_name | pigz -dc | python

Have you tried something like above? It worked for me when I tried with;

tail -f /var/log/syslog | grep `hostname` | python

Here's the Python I used courtesy of this post from Stackoverflow:

import sys 
import os

while True:
    line = sys.stdin.readline()
    if not line:
    sys.stdout.write(line) # or print, doesn't matter.
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .