1. import subprocess, string, time
  2.  
  3. args = 'java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui'.split()
  4.  
  5. p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  6.  
  7. thetime = time.time()
  8. print thetime
  9. #Watch and interface with the server
  10. while(True):
  11. if time.time() >= thetime + 5:
  12. thetime = time.time()
  13. p.stdin.write("say Saving...\n")
  14. time.sleep(1)
  15. p.stdin.write("save-all\n")
  16. p.stdin.write("say Map saved.\n")
  17. time.sleep(0.1)
  18. p.stderr.readline()
  19. log = p.stderr.readline()
  20. words = log.split()
  21. print log.strip()
  22. time.sleep(0.2)
  23.  
  24. print 'Script shutdown complete!'