I am trying to check the status of the tcpdump process on Linux inside a python script. (how to use ps cax | grep tcpdump > /dev/null in python or is there any other way?)
1 Answer
You can use the psutil module
import psutil
process = 'tcpdump'
print([p.info for p in psutil.process_iter(attrs=['pid', 'name']) if process in p.info['name']])