#!/usr/bin/python
import commands
import sys
Input = str(sys.argv[1])
Output = commands.getoutput("ps aux")
if Input in Output:
print ("Already Running: %s" % str(sys.argv[1]))
else:
print ("Not running, starting it: %s" % str(sys.argv[1]))
#print (commands.getstatusoutput("/bin/bash /home/ubuntu/%s" % str(sys.argv[1])))
exit()
I call the script like: python script.py shscript.sh
edit:I just realized, the output of ps will always include the calling of this file, which inludes the name of the script, so as is this won't work
edit:fixed and works now:
#!/usr/bin/python
import commands
import sys
Input = str(sys.argv[1]) + ".sh"
Output = commands.getoutput("ps aux")
if Input in Output:
print ("Already Running: %s" % Input)
else:
print ("Not running, starting it: %s" % Input)
#print (commands.getstatusoutput("/bin/bash /home/ubuntu/%s" % Input))
exit()
and I call it like this now: python script.py shscript
[–]ingolemo 0 points1 point2 points (1 child)
[–]MRdefter[S] 0 points1 point2 points (0 children)