Perl
Simple Shells to Fully Interactive TTYs
1. Python to spawn a PTY
2. Put the shell in to background with Ctrl-Z
3. Examine the current terminal and STTY info and match it
The information needed is the TERM type (“xterm-256color”) and the size of the current TTY (“rows 37; columns 146”)
4. Set the current STTY to type raw and tell it to echo the input characters
5. Foreground the shell with fg and re-open the shell with reset
6. stty size to match our current window
7. Set PATH TERM and SHELL if missing
1 2 3 4 5 | $ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin $ export TERM=xterm $ export SHELL=bash $ cat /etc/profile; cat /etc/bashrc; cat ~/.bash_profile; cat ~/.bashrc; cat ~/.bash_logout; env; set $ export PS1='[\u@\h \W]\$ ' |
1 |
No comments:
Post a Comment