Skip to content

Instantly share code, notes, and snippets.

@Jacajack
Created March 5, 2016 15:30
Show Gist options
  • Save Jacajack/e5b9aeb5534c98abdca2 to your computer and use it in GitHub Desktop.
Save Jacajack/e5b9aeb5534c98abdca2 to your computer and use it in GitHub Desktop.
Scanner for Minecraft servers - when server is down, run it to get notified when it's up again
#!/usr/bin/python3
import subprocess;
import time;
import os;
import sys;
try:
Address = sys.argv[1];
except:
Address = input( "Give me server IP: " );
Address.split( ' ', 1 )[0];
print( '\x1b[33;1m' + "Running port scan on " + Address + "..." + '\x1b[0m' );
while ( 1 ):
try:
Output = subprocess.check_output( "nmap -p 25560-25570 -v " + Address + " | grep \"25565/tcp open\"", shell=True );
except Exception:
Output = b'None found...';
Output = Output.decode( "ascii" );
if ( Output == "25565/tcp open minecraft\n" ):
print( '\x1b[32;1m' +"Minecraft server running detected!" + '\x1b[0m' );
os.system( "xmessage -center 'Minecraft server running detected!'" );
break;
else:
print( '\x1b[31;1m' +"None Minecraft server running detected..." + '\x1b[0m' );
time.sleep( 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment