Guest User

Untitled

a guest
Jan 16th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #!/bin/bash
  2. python /home2/ofekafsc/public_html/cgi-bin/wd.py
  3.  
  4. #!/usr/bin/python
  5. import subprocess
  6. import psutil
  7.  
  8. def running3(program, scriptname):
  9. for pid in psutil.pids(): # Iterates over all process-ID's found by psutil,
  10. try:
  11. p = psutil.Process(pid)
  12. if program in p.name():
  13. print(program)
  14. for arg in p.cmdline():
  15. print(arg)
  16. if scriptname in str(arg):
  17. return True
  18. else:
  19. pass
  20. else:
  21. pass
  22. except:
  23. continue
  24. if(running3("python", "serverListener.py")):
  25. print("RUNNING")
  26. sys.exit()
  27. else:
  28. subprocess.call("/home2/ofekafsc/public_html/cgi-bin/serverListener.py")
  29.  
  30. #!/usr/bin/python
  31. def verification():
  32. for pid in psutil.pids():
  33. p = psutil.Process(pid)
  34. if p.name() == "python" and len(p.cmdline()) > 1 and "serverListener.py" in p.cmdline()[1]:
  35. return True
  36.  
  37. if(verification()):
  38. sys.exit()
  39. else:
  40. subprocess.call("/home2/ofekafsc/public_html/cgi-bin/serverListener.py")
Add Comment
Please, Sign In to add comment