Please see the following code. Suppose I have many shell commands to be executed. And I don't want to fork a sub shell for each command(eg: status,output = commands.getstatusoutput(cmd)) because it is too expensive. I want to use only one sub shell to execute all these commands and want to get each command's output. How can I accomplish this task ? Thanks in advance.
=========================================== #!/usr/bin/env python import os fi, fo = os.popen2( ''' while read line do eval $line done ''', 't') #Suppose I have many commands to execute, but I don't want to fork a sub shell for each command cmds = ['date','uptime','pwd','ls -rltF','who'] for cmd in cmds: #pseudocode fi.executeCmd(cmd) output = fo.readResult() print output =========================================== -- http://mail.python.org/mailman/listinfo/python-list