OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 from __future__ import print_function |
| 3 |
| 4 import getpass |
| 5 import sys |
| 6 PY3 = (sys.version_info[0] >= 3) |
| 7 if not PY3: |
| 8 input = raw_input |
| 9 |
| 10 print("Mock SSH client for tests. Do not enter real security info.") |
| 11 |
| 12 pw = getpass.getpass('password:') |
| 13 if pw != 's3cret': |
| 14 print('Permission denied!') |
| 15 sys.exit(1) |
| 16 |
| 17 prompt = "$" |
| 18 while True: |
| 19 cmd = input(prompt) |
| 20 if cmd.startswith('PS1='): |
| 21 prompt = eval(cmd[4:]).replace('\$', '$') |
| 22 elif cmd == 'ping': |
| 23 print('pong') |
| 24 elif cmd.startswith('ls'): |
| 25 print('file1.py', 'file2.html', sep='\t') |
| 26 elif cmd == 'echo $?': |
| 27 print(0) |
| 28 elif cmd in ('exit', 'logout'): |
| 29 break |
OLD | NEW |