string.find() ?

Jay Collins jcollin at exis.net
Tue Mar 13 16:30:10 CET 2001


Hello,

 I'm using string.find to look for a string I get out of a popen() and it
doesn't appear to ever find what I'm looking for. Below is an example. It
always returns -1 no matter what I'm looking for. I was even looking for
root which should show up a bunch of times. Hopefully, someone can tell me
what I'm doing wrong.

-----------------------------<Cut Here>--------------------------------

import sys
import os
import string




output = os.popen('ps -auxww')
l = output.readlines()


size = len(l)
print "Size =",size
idx = 0



while idx < size:
        print string.find('snmpd',l[idx])
        idx = idx + 1





More information about the Python-list mailing list