| 14 | |
| 15 | |
| 16 | def windows(): # This is the function to run if it detects the OS is windows. |
| 17 | f = open("server_startup_" + strftime("%Y-%m-%d") + ".log", "a") # Open the logfile |
| 18 | for server in open( |
| 19 | "startup_list.txt", "r" |
| 20 | ): # Read the list of servers from the list |
| 21 | ret = subprocess.call( |
| 22 | "ping -n 3 %s" % server, |
| 23 | shell=True, |
| 24 | stdout=open("NUL", "w"), |
| 25 | stderr=subprocess.STDOUT, |
| 26 | ) # Ping the servers in turn |
| 27 | if ret == 0: # If you get a response. |
| 28 | f.write( |
| 29 | "%s: is alive, loading PuTTY session" % server.strip() + "\n" |
| 30 | ) # Write out to the logfile |
| 31 | subprocess.Popen(("putty -load " + server)) # Load the putty session |
| 32 | else: |
| 33 | f.write( |
| 34 | "%s : did not respond" % server.strip() + "\n" |
| 35 | ) # Write to the logfile if the server is down |
| 36 | |
| 37 | |
| 38 | def linux(): |