GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Python/powerdown_startup.py at master · rajendar19/Python Expand file tree/ Copy pathpowerdown_startup.pyMore file actions 42 lines (34 loc) · 2.08 KB / Copy pathpowerdown_startup.pyFile metadata and controls42 lines (34 loc) · 2.08 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 # Script Name : powerdown_startup.py # Author : Craig Richards # Created : 05th January 2012 # Last Modified : # Version : 1.0 # Modifications : # Description : This goes through the server list and pings the machine, if it's up it will load the putty session, if its not it will notify you. import os # Load the Library Module import subprocess # Load the Library Module from time import strftime # Load just the strftime Module from Time def windows(): # This is the function to run if it detects the OS is windows. f = open('server_startup_'+strftime("%Y-%m-%d")+'.log', 'a') # Open the logfile for server in open('startup_list.txt','r'): # Read the list of servers from the list ret = subprocess.call("ping -n 3 %s" % server, shell=True,stdout=open('NUL', 'w'),stderr=subprocess.STDOUT) # Ping the servers in turn if ret == 0: # If you get a response. f.write ("%s: is alive, loading PuTTY session" % server.strip() + "\n") # Write out to the logfile subprocess.Popen(('putty -load '+server)) # Load the putty session else: f.write ("%s : did not respond" % server.strip() + "\n") # Write to the logfile if the server is down def linux(): f = open('server_startup_'+strftime("%Y-%m-%d")+'.log', 'a') # Open the logfile for server in open('startup_list.txt'): # Read the list of servers from the list ret = subprocess.call("ping -c 3 %s" % server, shell=True,stdout=open('/dev/null', 'w'),stderr=subprocess.STDOUT) # Ping the servers in turn if ret == 0: # If you get a response. f.write ("%s: is alive" % server.strip() + "\n") # Print a message subprocess.Popen(['ssh', server.strip()]) else: f.write ("%s: did not respond" % server.strip() + "\n") # End of the functions # Start of the Main Program if os.name == "posix": # If the OS is linux... linux() # Call the linux function elif os.name in ("nt", "dos", "ce"): # If the OS is Windows... windows() # Call the windows function |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |