How to do this in Python?

Philippe C. Martin philippecmartin at
Wed Nov 17 22:04:38 CET 2004



>>I just started using python. In Perl, I could do something like this to
>>process the output of ps:

>>$result = `ps -ef | grep myprog`. Then the $result contains the result from
>>this command line.

>>How can I do similar things in python?

One way:

import os
res = os.popen('ps -e | grep myprog').readlines()



More information about the Python-list mailing list