Hello, If I have multiple Popen calls I need to make, how can I turn these into a function?
from subprocess import Popen, PIPE p1 = Popen(['ls', '-l', '-a', '/etc'],stdout=PIPE) p2 = Popen(['grep', 'hosts'], stdin=p1.stdout, stdout=PIPE) p3 = Popen(['awk', '{print $1}'], stdin=p2.stdout, stdout=PIPE) output = p3.communicate()[0] p1 = Popen(['ps', '-ef'], stdout=PIPE) p2 = Popen(['grep', '-v', '2348'], stdin=p1.stdout, stdout=PIPE) output = p2.communicate()[0] I would be sending an arbitrary number of PIPES with each function call. I'm a little stumped as to how to handle the variables. If I have an arbitrary number of PIPES, how do I declare my variables (p1, p2, p3, etc...) ahead of time in the function?? Thanks for any suggestions! Jay
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor