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, stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0])
Allowed me to append the subprocess output to my list. Thanks for the help everyone :-) On Mon, Nov 16, 2015 at 3:07 PM, Vusa Moyo <sow...@gmail.com> wrote: > The following code seems to be pointing me to the right direction, BUT, my > list has 0's instead of the output generated. > > >>> for i in range(len(pids)): > ... final.append(subprocess.call(["sudo pmap -d %s | grep private |awk > '{print $1}' | awk -FK '{print $1}'" % pids[i]], shell=True)) > ... > 60772 > 106112 > 3168 > 13108 > 14876 > 8028 > 3328 > 8016 > 139424 > 6037524 > 5570492 > 4128 > 144364 > 154980 > 154980 > >>> pmap_str > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] > > I;m assuming the zero's are exit codes, which then populate the list, > which is not what I'm after. . > > On Mon, Nov 16, 2015 at 2:17 PM, Vusa Moyo <sow...@gmail.com> wrote: > >> Hi Guys, >> >> OS = SuSE Enterprise Linux >> Python V2.7 >> >> My code is as follows >> >> # this list contains system process ID's >> pidst=[1232, 4543, 12009] >> >> pmap_str=[] >> command="pmap -d %s | grep private |awk '{print $1}' | awk -FK '{print >> $1}'" >> >> for i in range(len(pids)): >> pmap_str.append(os.popen("(command) % pidlist_int[i])")) # <-- >> this is where I need help, please >> >> As I'm sure you can see, I'm trying to output the os.popen output to a >> new list. >> >> On the shell console I can run the pmap command as follows >> >> pmap -d <PID> | grep private |awk '{print $1}' | awk -FK '{print $1}' >> >> Output will be a single number such as 485921. >> >> My error is on the line of code shown above. Please assist. >> >> Kind Regards >> > > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor