Created
May 17, 2017 04:27
-
-
Save tacahiroy/1b2584ab962465fcdeb34adeb2e15871 to your computer and use it in GitHub Desktop.
Runs a command in a fake tty and gets output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os,sys,time | |
| os.environ['TERM'] = 'xterm' | |
| pid,fd = os.forkpty() | |
| if pid == 0: | |
| os.execv('/sbin/esxtop', []) | |
| sys.exit(0) | |
| else: | |
| out = os.read(fd,300) | |
| print(out) | |
| os.write(fd,'/sbin/esxtop\n') | |
| time.sleep(1) | |
| out = os.read(fd,300) | |
| print(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment