In the main PC I run:
$mkfifo foo; script -f foo
In the second PC, I log in via ssh and then run in the terminal:
$cat foo
Now whatever I run in the 1st PC's terminal, it gets showed (including all the verbose output) in the second PC.
This simple solution has a minor drawback, second PC's terminal becomes read-only, You don't get any kind of interactivity from the second shell. To solve this problem we'll take help of another tool, GNU 'screen'.
#apt-get install screen
$vi ~/.screenrc
Add these lines:
hardstatus onNow comes the most important part:
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
In the main PC I open a shell:
$screen
Now I log in via ssh from the remote PC and run this in shell:
$screen -x
Now whatever I run in the first PC, I get another output in the second terminal and both the terminal's are interactive.
Now you can ask, what if I want to close either of the screens and keep the other one active? Just press Ctrl + a, d in any screen. The screen gets detached.
If you want to resume an already detached screen:
$screen -r
Some tips:
- Screen can also manage multiple terminal sessions in it. To create new tab, Ctrl + a, c and then you can cruise between the tabs by pressing Ctrl + a, Ctrl + a repeatedly.
- Ctrl + a, " shows you the list of available tabs
- Ctrl + a, A gives you a promt to change the name of current tab
- Ctrl + a, k closes the current tab
- Ctrl + a, S splits the currnt window into two separete workspaces, You can browse between them by Ctrl + a, TAB
- You can also run 'screen' in a nested manner. Cool huh!
http://www.kuro5hin.org/story/2004/3/9/16838/14935
No comments:
Post a Comment