|  | #!/usr/bin/env python | 
|  | from __future__ import print_function | 
|  |  | 
|  | import getpass | 
|  | import sys | 
|  | PY3 = (sys.version_info[0] >= 3) | 
|  | if not PY3: | 
|  | input = raw_input | 
|  |  | 
|  | print("Mock SSH client for tests. Do not enter real security info.") | 
|  |  | 
|  | pw = getpass.getpass('password:') | 
|  | if pw != 's3cret': | 
|  | print('Permission denied!') | 
|  | sys.exit(1) | 
|  |  | 
|  | prompt = "$" | 
|  | while True: | 
|  | cmd = input(prompt) | 
|  | if cmd.startswith('PS1='): | 
|  | prompt = eval(cmd[4:]).replace('\$', '$') | 
|  | elif cmd == 'ping': | 
|  | print('pong') | 
|  | elif cmd.startswith('ls'): | 
|  | print('file1.py', 'file2.html', sep='\t') | 
|  | elif cmd == 'echo $?': | 
|  | print(0) | 
|  | elif cmd in ('exit', 'logout'): | 
|  | break |