All pastes #349191 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-02-10 17:03 UTC
rendered paste body
processes = openPipe(["ps", "-A"])

found = []
for arg in sys.argv[1:]:
  match = False
  for line in processes:
    if arg in line:
      found.append(line)
      match = True
  if not match:
    print "%s was not found!" % arg
    time.sleep(2)

if not found:
  sys.exit("No matches found")

pids = []
for line in found:
  pid = line.strip().split(" ")[0]
  pids.append(pid)

param = ""
for pid in pids:
  param += "-p%s " % pid

os.system("top %s" % param)