#!/usr/bin/python3 """Where is root? A simple pipeline example without the shell. From . """ import subprocess, sys def root(): p1 = subprocess.Popen(["df"], stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "/$"], stdin=p1.stdout, stdout=subprocess.PIPE) p1.stdout.close() return p2.communicate()[0] if __name__ == '__main__': sys.stdout.buffer.write(root())