Skip to content

Instantly share code, notes, and snippets.

@mortymacs
Created July 22, 2013 04:39
Show Gist options
  • Select an option

  • Save mortymacs/6051308 to your computer and use it in GitHub Desktop.

Select an option

Save mortymacs/6051308 to your computer and use it in GitHub Desktop.
Show status of your favorite programs
#!/usr/bin/env python
import subprocess
def check():
plist = open("plist").readlines()
for i in plist:
if i[:1] == "#":
continue
cline = i.split()
a = subprocess.Popen("%s &>/dev/null;echo $?" % ' '.join(cline[2:]),shell=True,stdout=subprocess.PIPE)
result = a.stdout.readlines()[0]
if result[:-1] == cline[1]:
print "Success"
else:
print "Error"
if __name__ == "__main__":
check()
------------------------
Sample data of plist:
# name exit command
# ---------------------------
httpd 0 service httpd status
sshd 0 service sshd status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment