Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import pexpect, time, signal, getpass, sys
  4.  
  5. x = 1
  6.  
  7. def mode(sig, data):
  8.     global x
  9.     x = 0
  10.    
  11. def get_name():
  12.     user = raw_input("Username: ")
  13.     password = getpass.getpass("Password: ")
  14.     idle(user,password)
  15.    
  16. def idle(user,password):
  17.     mud = pexpect.spawn('telnet game.mortalrealms.com 4321')
  18.     mud.expect('Who art thou:')
  19.     mud.sendline(user)
  20.     print mud.before,mud.after,
  21.     mud.expect('Password:')
  22.     mud.sendline(password)
  23.     mud.expect('Press return to continue:')
  24.     mud.sendline('\n')
  25.     print mud.before, mud.after,
  26.          
  27.     while x != 0:
  28.         mud.sendline('\n')
  29.         time.sleep(20)
  30.  
  31.     mud.interact()
  32.  
  33.     if mud.isalive():
  34.         mud.sendline('quit')
  35.         mud.close()
  36.     # Print the final state of the child. Normally isalive() should be FALSE.
  37.     if mud.isalive():
  38.         print 'Child did not exit gracefully.'
  39.     else:
  40.         print 'Child exited gracefully.'
  41.                                
  42.    
  43. if __name__ == "__main__":
  44.     signal.signal(signal.SIGINT, mode)
  45.     get_name()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement