Re: [Tutor] os.popen - using commands and input %

2015-11-17 Thread Danny Yoo
On Mon, Nov 16, 2015 at 4:17 AM, Vusa Moyo wrote: > Hi Guys, > > 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_s

Re: [Tutor] os.popen - using commands and input %

2015-11-16 Thread Alan Gauld
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.

Re: [Tutor] os.popen - using commands and input %

2015-11-16 Thread Vusa Moyo
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

Re: [Tutor] os.popen - using commands and input %

2015-11-16 Thread Vusa Moyo
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

[Tutor] os.popen - using commands and input %

2015-11-16 Thread Vusa Moyo
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) %