hi all...

whats the difference between os.popen and subprocess.popen??

what does shell=True in subprocess.call really mean?

if os.popen is used for snmpwalk, will there be any problem such as exceeding pipe capacity? what is the capacity of the file objcet connected to pipe using os.popen?/ how much data can it hold?

The os.popen and related functions are simple wrappers around the C popen functions. They were the normal way to start subprocesses before the subprocess module appeared in python. Today's code should use the subprocess module instead of os.popen (actually, the subprocess module calls the os.popen functions). Also if you only want to fork python programs, you can use the new multiprocessing module (formerly called pyprocessing).

shell=True means that your program is executed through a shell. In linux for example, a statement like Popen("ls", shell=True) starts 2 processes actually: a /bin/sh process which executes the command ls by starting a 'ls' process. With shell=True, the first argument to Popen must be a string (similar to the command line you would enter in a terminal). Without shell=True, there is no command line interpreter to parse your command, and the first argument must be a list of all command line argument parsed by yourself. In certain cases it's better to run with shell=True and in other cases without it.

If you are using the Popen.communicate method to get the output and error of your command, the pipe's size is not a problem: python reads repeatedly from the pipe and builds a string. However, if your program outputs gigabytes, you may exhaust your RAM.

An alternative is to try to read from the subprocess while it is running. This is not always easy because of blocking reads. I once found a nice solution to this problem in linux only. See this post http://www.daniweb.com/forums/post777876.html#post777876 .