Mar-12-2020, 07:16 AM
(This post was last modified: Mar-12-2020, 07:56 AM by Manikandan_PS.)
understood...thought of moving the question to the appropriate group and surely not to repeat the question again.
yes i passed shell=True and i get 3 consecutive PID's, 1 for shell and the others for tail and egrep as seen through command "ps -ae" but, when shell pid is killed the other two still remains.
i am just trying these commands over python shell to see the behavior and then finally to use it in my script:
###############from python shell environment############
import os
import subprocess
command_1 = "tail -f file1*.log -f file2* -f file3* | egrep --line-buffered "string1:|string2" > /export/home/output.txt &"
p = subprocess.Popen(command_1,stdin=subprocess.PIPE,stdout=subprocess.PIPE,shell=True)
(out,error) = p.communicate()
###############from python shell environment############
1] p.pid says 22559 and 22560 for tail and 22561 for egrep as seen through linux command <ps -ae>
2] upon calling p.terminate(), i don't see pid 22559 but the other pid's 22560 and 22561 still remains. how to terminate all these pids ?
yes i passed shell=True and i get 3 consecutive PID's, 1 for shell and the others for tail and egrep as seen through command "ps -ae" but, when shell pid is killed the other two still remains.
i am just trying these commands over python shell to see the behavior and then finally to use it in my script:
###############from python shell environment############
import os
import subprocess
command_1 = "tail -f file1*.log -f file2* -f file3* | egrep --line-buffered "string1:|string2" > /export/home/output.txt &"
p = subprocess.Popen(command_1,stdin=subprocess.PIPE,stdout=subprocess.PIPE,shell=True)
(out,error) = p.communicate()
###############from python shell environment############
1] p.pid says 22559 and 22560 for tail and 22561 for egrep as seen through linux command <ps -ae>
2] upon calling p.terminate(), i don't see pid 22559 but the other pid's 22560 and 22561 still remains. how to terminate all these pids ?
(Mar-12-2020, 07:16 AM)Manikandan_PS Wrote: understood...thought of moving the question to the appropriate group and surely not to repeat the question again.both out and error were returning empty but when i execute this command on a linux shell environment i get the pids for both tail and egrep. how to get these two pid's in python ?
yes i passed shell=True and i get 3 consecutive PID's, 1 for shell and the others for tail and egrep as seen through command "ps -ae" but, when shell pid is killed the other two still remains.
i am just trying these commands over python shell to see the behavior and then finally to use it in my script:
###############from python shell environment############
import os
import subprocess
command_1 = "tail -f file1*.log -f file2* -f file3* | egrep --line-buffered "string1:|string2" > /export/home/output.txt &"
p = subprocess.Popen(command_1,stdin=subprocess.PIPE,stdout=subprocess.PIPE,shell=True)
(out,error) = p.communicate()
###############from python shell environment############
1] p.pid says 22559 and 22560 for tail and 22561 for egrep as seen through linux command <ps -ae>
2] upon calling p.terminate(), i don't see pid 22559 but the other pid's 22560 and 22561 still remains. how to terminate all these pids ?