Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import pexpect, time, signal, getpass, sys
- x = 1
- def mode(sig, data):
- global x
- x = 0
- def get_name():
- user = raw_input("Username: ")
- password = getpass.getpass("Password: ")
- idle(user,password)
- def idle(user,password):
- mud = pexpect.spawn('telnet game.mortalrealms.com 4321')
- mud.expect('Who art thou:')
- mud.sendline(user)
- print mud.before,mud.after,
- mud.expect('Password:')
- mud.sendline(password)
- mud.expect('Press return to continue:')
- mud.sendline('\n')
- print mud.before, mud.after,
- while x != 0:
- mud.sendline('\n')
- time.sleep(20)
- mud.interact()
- if mud.isalive():
- mud.sendline('quit')
- mud.close()
- # Print the final state of the child. Normally isalive() should be FALSE.
- if mud.isalive():
- print 'Child did not exit gracefully.'
- else:
- print 'Child exited gracefully.'
- if __name__ == "__main__":
- signal.signal(signal.SIGINT, mode)
- get_name()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement