Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: adam100 on May 16th, 2012  |  syntax: None  |  size: 0.40 KB  |  hits: 73  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import pexpect
  2.  
  3. SERVER = { 1: 'server1',
  4.             2: 'server2',
  5.             3: 'server3',
  6.             etc }
  7. for key in sorted(SERVER):
  8.         print key, SERVER[key]
  9.  
  10. CHOICE = int(input("Type in server number: "))
  11. HOST = SERVER[CHOICE]
  12. USER="username"
  13. PASS="password"
  14. COMMAND="ssh -vNCD 23333 USER@HOST"
  15.  
  16. child = pexpect.spawn(COMMAND)
  17. child.expect('Password:')
  18. child.sendline(PASS)
  19. child.interact()