latest = subprocess.check_output( ['tail', '-n', '1', '/root/server/logs/latest.log'], encoding='utf-8') matches = re.search(r'<(.*?)> (.*)', latest) if matches is None: time.sleep(0.5) continue name = matches.group(1) typed = matches.group(2) idx = typed.find(' ') if idx != -1: cmd = typed[:idx].lower() args = typed[idx + 1:].lower() else: cmd = typed.lower() args = None try: command = callbacks[cmd] except KeyError: continue try: command(name, args) except: rcon.say('You typed the command wrong Pepega :)') rcon.disconnect()