Skip to content

Instantly share code, notes, and snippets.

@tsu-nera
Created October 29, 2017 08:27
Show Gist options
  • Save tsu-nera/cc1ff3b0b5fcfd049d428608a2ea496a to your computer and use it in GitHub Desktop.
Save tsu-nera/cc1ff3b0b5fcfd049d428608a2ea496a to your computer and use it in GitHub Desktop.
#!/usr/bin/python2
import subprocess
import re
try:
res = subprocess.check_output(['ps', '-e'])
except:
print "Error."
lines = res.splitlines()[1:]
pidname = dict()
for l in lines:
sp = l.split()
pidname[sp[0]] = sp[3]
search_path = ['/opt/google/chrome', '/usr/share/atom']
try:
res = subprocess.check_output(['ps', '-e', '-f'])
except:
print "Error."
lines = res.splitlines()[1:]
for path in search_path:
for l in lines:
sp = l.split()
if sp[7].find(path) > -1:
try:
res = subprocess.check_output(['gcore', '-o', pidname[sp[1]], sp[1]])
except:
print "Error."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment