Created
July 22, 2013 04:39
-
-
Save mortymacs/6051308 to your computer and use it in GitHub Desktop.
Show status of your favorite programs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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