#!/usr/bin/python

import os

def pskill(processString):
  """grep a process with a full blown string and kill it"""
  p = os.popen('ps aux | grep "' + processString + '"')
  lines = p.readlines()
  print lines
  p.close()

  for x in lines:
    if processString in x and 'grep' not in x:
      pid = x.replace('   ',' ').replace('  ',' ').split()[1]
      print x
      print 'PID is',pid
      print 'kill -9 '+pid
      os.system('kill -9 '+pid)
      break

if __name__ == '__main__':
  pskill('python doctor.fcgi')
  os.system('/home/frostwire/doctor.frostwire.com/run')
