linux tee is not responding

From man python: -u Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode. Note that there is internal buffering in xreadlines(), readlines() and file- object iterators (“for line in sys.stdin”) which is not influenced by this option. To work around this, … Read more

How can I gzip standard in to a file and also print standard in to standard out?

Another way (assuming a shell like bash or zsh): echo “hey hey, we’re the monkees” | tee >(gzip –stdout > my_log.gz) The admittedly strange >() syntax basically does the following: Create new FIFO (usually something in /tmp/) Execute command inside () and bind the FIFO to stdin on that subcommand Return FIFO filename to command … Read more

How to tee to stderr?

The only cross platform method I found which works in both interactive and non-interactive shells is: command | tee >(cat 1>&2) The argument to tee is a file or file handle. Using process substitution we send the output to a process. In the process =cat=, we redirect stdout to stderr. The shell (bash/ksh) is responsible … Read more

How to replicate tee behavior in Python when using subprocess?

I see that this is a rather old post but just in case someone is still searching for a way to do this: proc = subprocess.Popen([“ping”, “localhost”], stdout=subprocess.PIPE, stderr=subprocess.PIPE) with open(“logfile.txt”, “w”) as log_file: while proc.poll() is None: line = proc.stderr.readline() if line: print “err: ” + line.strip() log_file.write(line) line = proc.stdout.readline() if line: print … Read more

linux tee is not working with python?

From man python: -u Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode. Note that there is internal buffering in xreadlines(), readlines() and file- object iterators (“for line in sys.stdin”) which is not influenced by this option. To work around this, … Read more