On 16/11/15 14:05, Vusa Moyo wrote:
SOLVED> the code I used was.
for i in range(len(pids)):
final.append(subprocess.Popen(["sudo pmap -d %s | grep private |awk
'{print $1}' | awk -FK '{print $1}'" % pids[i]], shell=True,
Glad you solved it and using subprocess is fine for the pmap stuff.
But the grep and awk stuff are usually a lot faster and almost as
easy using Python.
eg.
for line in pmap_output
if private in line:
print line.split()[0] # {print $1}
Or, to create a list instead of printing
col1 = [line.split()[0] for line in pmap_output if private in line]
I can't remember what -FK does (F is field sep but K?)
But I'm fairly sure it will be easy to replicate in Python.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor