Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- python /home2/ofekafsc/public_html/cgi-bin/wd.py
- #!/usr/bin/python
- import subprocess
- import psutil
- def running3(program, scriptname):
- for pid in psutil.pids(): # Iterates over all process-ID's found by psutil,
- try:
- p = psutil.Process(pid)
- if program in p.name():
- print(program)
- for arg in p.cmdline():
- print(arg)
- if scriptname in str(arg):
- return True
- else:
- pass
- else:
- pass
- except:
- continue
- if(running3("python", "serverListener.py")):
- print("RUNNING")
- sys.exit()
- else:
- subprocess.call("/home2/ofekafsc/public_html/cgi-bin/serverListener.py")
- #!/usr/bin/python
- def verification():
- for pid in psutil.pids():
- p = psutil.Process(pid)
- if p.name() == "python" and len(p.cmdline()) > 1 and "serverListener.py" in p.cmdline()[1]:
- return True
- if(verification()):
- sys.exit()
- else:
- subprocess.call("/home2/ofekafsc/public_html/cgi-bin/serverListener.py")
Add Comment
Please, Sign In to add comment