Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Eavesdropping on another terminal...
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
npmccallum
Retired Dev
Retired Dev


Joined: 09 May 2003
Posts: 306
Location: Lexington, KY

PostPosted: Fri May 23, 2003 6:15 pm    Post subject: Eavesdropping on another terminal... Reply with quote

I am currently running a very very long process on a box in another room (it is running on the first virtual terminal). I would like to log in (as root of course), via ssh (which is setup), and view what is going on on the screen of virtual terminal 1 (to monitor the progress). How do I do this?
Back to top
View user's profile Send private message
jimlynch11
Guru
Guru


Joined: 21 Feb 2003
Posts: 590
Location: massachusetts

PostPosted: Fri May 23, 2003 6:17 pm    Post subject: Reply with quote

i was wondering about the same thing today...i think there is a way you can send all of the output to a log file, then monitor that...im not sure how to set it up or if it is the best option
Back to top
View user's profile Send private message
blscreen
Tux's lil' helper
Tux's lil' helper


Joined: 04 Mar 2003
Posts: 118
Location: Innsbruck

PostPosted: Fri May 23, 2003 9:00 pm    Post subject: Reply with quote

If you know that you want to monitor the process before starting it, 'screen' would fit your needs. You can start whatever you like in screen and then detach and resume remotely. This does not help you if you cannot interrupt the running process though :?
Back to top
View user's profile Send private message
npmccallum
Retired Dev
Retired Dev


Joined: 09 May 2003
Posts: 306
Location: Lexington, KY

PostPosted: Fri May 23, 2003 9:31 pm    Post subject: Reply with quote

blscreen wrote:
If you know that you want to monitor the process before starting it, 'screen' would fit your needs. You can start whatever you like in screen and then detach and resume remotely. This does not help you if you cannot interrupt the running process though :?


What does 'screen' do?
Back to top
View user's profile Send private message
Reverend
n00b
n00b


Joined: 19 Mar 2003
Posts: 22

PostPosted: Fri May 23, 2003 9:49 pm    Post subject: Reply with quote

blscreen wrote:
If you know that you want to monitor the process before starting it, 'screen' would fit your needs. You can start whatever you like in screen and then detach and resume remotely. This does not help you if you cannot interrupt the running process though :?


You know, I can never seem to figure out how to use this program. The man page tells you everything that you might want to do, but doesn't just break it down to the most common sequence of commands.

Say for example, I'm at work and start up a 'emerge -u kde' and I know it's going to be running for a while over the weekend. So, I want to run it inside screen so that I can check on it from home over the weekend. What do I do?

Do I run screen, then execute the emerge command from within? Then what do I do at home?

Could you, or someone, please just give an example set of commands and keystrokes sent to screen to be able to periodically check in on a long running process?

Thanks!
Back to top
View user's profile Send private message
MacFlecknoe
Apprentice
Apprentice


Joined: 11 Feb 2003
Posts: 189
Location: Ann Arbor, MI

PostPosted: Fri May 23, 2003 9:58 pm    Post subject: Reply with quote

look in this months Linux Magazine... they have a nice writeup on the 'screen' program; you can pick a copy up at Barnes & Nobles
Back to top
View user's profile Send private message
aardvark
Guru
Guru


Joined: 30 Jun 2002
Posts: 576

PostPosted: Fri May 23, 2003 10:06 pm    Post subject: Reply with quote

Reverend wrote:
blscreen wrote:
If you know that you want to monitor the process before starting it, 'screen' would fit your needs. You can start whatever you like in screen and then detach and resume remotely. This does not help you if you cannot interrupt the running process though :?


You know, I can never seem to figure out how to use this program. The man page tells you everything that you might want to do, but doesn't just break it down to the most common sequence of commands.

Say for example, I'm at work and start up a 'emerge -u kde' and I know it's going to be running for a while over the weekend. So, I want to run it inside screen so that I can check on it from home over the weekend. What do I do?

Do I run screen, then execute the emerge command from within? Then what do I do at home?

Could you, or someone, please just give an example set of commands and keystrokes sent to screen to be able to periodically check in on a long running process?

Thanks!


screen is easy
just emerge it
the type screen
do your stuff...
then hit ctrl+a d
now connect to that screen again (even fom an ssh session) with
Code:
 screen -r

It is alsi possible to connect to a screen that is attached

I believe it is screen -x....

check the manpage
Back to top
View user's profile Send private message
npmccallum
Retired Dev
Retired Dev


Joined: 09 May 2003
Posts: 306
Location: Lexington, KY

PostPosted: Fri May 23, 2003 10:12 pm    Post subject: Reply with quote

There is no way to do this without screen? Shouldn't root be able to see other people's sessions? or is this disabled for security reasons?
Back to top
View user's profile Send private message
aardvark
Guru
Guru


Joined: 30 Jun 2002
Posts: 576

PostPosted: Fri May 23, 2003 10:21 pm    Post subject: Reply with quote

npmccallum wrote:
There is no way to do this without screen? Shouldn't root be able to see other people's sessions? or is this disabled for security reasons?


screen is a small program. I don't see why you would do it an other way.
I once looked for a solution for the issue you mention (for 2 whole hours...:( ), and the only practical "hassle free" solution I found was .... screen... . When I know I'm not going to be on he same terminal for a certain operation I always just start the process in a sceen...
Even my server adsl script on the server runs in a screen so that I can check it out when the connection seems down :)
Back to top
View user's profile Send private message
npmccallum
Retired Dev
Retired Dev


Joined: 09 May 2003
Posts: 306
Location: Lexington, KY

PostPosted: Fri May 23, 2003 10:49 pm    Post subject: Reply with quote

aardvark wrote:

screen is a small program. I don't see why you would do it an other way.
I once looked for a solution for the issue you mention (for 2 whole hours...:( ), and the only practical "hassle free" solution I found was .... screen... . When I know I'm not going to be on he same terminal for a certain operation I always just start the process in a sceen...
Even my server adsl script on the server runs in a screen so that I can check it out when the connection seems down :)


'screen' doesn't help when you are doing a system install :(
Back to top
View user's profile Send private message
blscreen
Tux's lil' helper
Tux's lil' helper


Joined: 04 Mar 2003
Posts: 118
Location: Innsbruck

PostPosted: Sat May 24, 2003 1:38 am    Post subject: Reply with quote

Quote:
Could you, or someone, please just give an example set of commands and keystrokes sent to screen to be able to periodically check in on a long running process?


Start with
Code:
screen

This drops you into your shell, you don't notice any differences. Then start whatever is going to run a long time.
You can create more virtual terminals in the current screen session:
Code:
Ctrl-a c
It is possible to switch between the terminals with
Code:
Ctrl-a 0..9
(direct access) or with
Code:
Ctrl-a n
(go to the next terminal).
As mentioned before
Code:
Ctrl-a d
detaches the current screen session with all of its virtual terminals. To resume, just type
Code:
screen -r
or
Code:
screen -d -r
if the session has not yet been detached (connection broke or something).

This are the commands I use most (mainly to chat over an irssi running at home when I am at my working place, so I don't need to install a client on this windows box) ;)
Back to top
View user's profile Send private message
blscreen
Tux's lil' helper
Tux's lil' helper


Joined: 04 Mar 2003
Posts: 118
Location: Innsbruck

PostPosted: Sat May 24, 2003 1:59 am    Post subject: Reply with quote

Quote:
'screen' doesn't help when you are doing a system install


Well, you have to install some software before you can do the monitoring. If you have installed sshd, why not as well screen, or am I getting something wrong here :roll:?

Another possibility is 'ttysnoop', which is a client-server based solution. The server 'ttysnoops' is started by agetty instead of /bin/login (ttysnoops now takes care about that). With the client 'ttysnoop' you can then watch what is going on in this terminal. This is more of a spyware than 'screen' because the users might not know that their actions are under observation.
Back to top
View user's profile Send private message
npmccallum
Retired Dev
Retired Dev


Joined: 09 May 2003
Posts: 306
Location: Lexington, KY

PostPosted: Sat May 24, 2003 2:06 am    Post subject: Reply with quote

blscreen wrote:
Quote:
'screen' doesn't help when you are doing a system install


Well, you have to install some software before you can do the monitoring. If you have installed sshd, why not as well screen, or am I getting something wrong here :roll:?

Another possibility is 'ttysnoop', which is a client-server based solution. The server 'ttysnoops' is started by agetty instead of /bin/login (ttysnoops now takes care about that). With the client 'ttysnoop' you can then watch what is going on in this terminal. This is more of a spyware than 'screen' because the users might not know that their actions are under observation.


If its not on the gentoo live cd (sshd is on the cd), I can't monitor the installs going on in the other room :)
Back to top
View user's profile Send private message
dma
Guru
Guru


Joined: 31 Jan 2003
Posts: 437
Location: Charlotte, NC, USA

PostPosted: Sat May 24, 2003 2:11 am    Post subject: Reply with quote

It can be done through /dev/vcsa*

It dumps the contents of a VC to the current terminal (including colors).

You can type "man vcsa" for more info.

I'll make you a prog to dump it to your console (THIS IS HORRIBLY INEFFICIENT!):

Code:
#!/usr/bin/perl

%COLORMAP = (
    0 => 0,    1 => 4,    2 => 2,    3 => 6,
    4 => 1,    5 => 5,    6 => 3,    7 => 7 );


if ($#ARGV != 0) {
    die "$0: must give a vcsa device.\n";
}

$F = $ARGV[0];

open(VCSA, "<$F") or die "$0: unable to open $F ($!)\n";

my $Columns = ord(getc(VCSA));
my $Lines = ord(getc(VCSA));

my $CurX = ord(getc(VCSA));
my $CurY = ord(getc(VCSA));

my $LINE = 0;
my $COL = 0;

my $ATTR;
my $CHAR;

# Main stuff.

for ($COL = 0; $COL < $Columns; $COL++) {
    for ($LINE = 0; $LINE < $Lines; $LINE++) {
        $CHAR = getc(VCSA);
        $ATTR = ord(getc(VCSA));


        print "\e[0;";

        my $bg_col = $COLORMAP{ ($ATTR & 0x70) >> 4 };
        print "4", $bg_col, ";";
        my $fg_col = $COLORMAP{ ($ATTR & 0x07) };
        if ( ($ATTR & 0x0F) >= 0x08 ) {
            print "1;";
        }
        print "3", $fg_col, "m";
        print $CHAR;
    }
    print "\n";
}

close(VCSA);
Back to top
View user's profile Send private message
jkcunningham
l33t
l33t


Joined: 28 Apr 2003
Posts: 649
Location: 47.49N 121.79W

PostPosted: Sat May 24, 2003 3:15 am    Post subject: Reply with quote

If you are really opposed to screen, there is another way: ssh into the remote machine and launch it via the ssh window. Then its right there for you to watch. Of course, if you move to the remote terminal, so that its local, you won't be able to see it anymore. Just a thought.

-Jeff
Back to top
View user's profile Send private message
npmccallum
Retired Dev
Retired Dev


Joined: 09 May 2003
Posts: 306
Location: Lexington, KY

PostPosted: Sat May 24, 2003 4:23 am    Post subject: Reply with quote

jkcunningham wrote:
If you are really opposed to screen, there is another way: ssh into the remote machine and launch it via the ssh window. Then its right there for you to watch. Of course, if you move to the remote terminal, so that its local, you won't be able to see it anymore. Just a thought.

-Jeff


Thats what I've been doing. But somtimes I have to shut down the computer I'm observing from and I don't want to interrupt the install. Oh well.

(I'm not OPPOSED to screen, it just isn't on the Gentoo Live CD. Or is it!?)
Back to top
View user's profile Send private message
dma
Guru
Guru


Joined: 31 Jan 2003
Posts: 437
Location: Charlotte, NC, USA

PostPosted: Sat May 24, 2003 1:00 pm    Post subject: Reply with quote

The program I wrote a few posts back will dump the current contents of a console (/dev/vcsa1 for #1) to your machine over ssh or whatever. It isn't optimized and it requires perl... But I only spent a few minutes writing it.

It is like taking a remote screen shot. Requires no previous work on the console in question.
Back to top
View user's profile Send private message
jimlynch11
Guru
Guru


Joined: 21 Feb 2003
Posts: 590
Location: massachusetts

PostPosted: Wed May 28, 2003 12:04 pm    Post subject: Reply with quote

blscreen wrote:
Quote:
Could you, or someone, please just give an example set of commands and keystrokes sent to screen to be able to periodically check in on a long running process?


Start with
Code:
screen

This drops you into your shell, you don't notice any differences. Then start whatever is going to run a long time.
You can create more virtual terminals in the current screen session:
Code:
Ctrl-a c
It is possible to switch between the terminals with
Code:
Ctrl-a 0..9
(direct access) or with
Code:
Ctrl-a n
(go to the next terminal).
As mentioned before
Code:
Ctrl-a d
detaches the current screen session with all of its virtual terminals. To resume, just type
Code:
screen -r
or
Code:
screen -d -r
if the session has not yet been detached (connection broke or something).

This are the commands I use most (mainly to chat over an irssi running at home when I am at my working place, so I don't need to install a client on this windows box) ;)


blscreen: you are my hero. the program screen is the best thing ever!
Back to top
View user's profile Send private message
bos_mindwarp
Apprentice
Apprentice


Joined: 19 Oct 2002
Posts: 275
Location: stockholm, sweden

PostPosted: Wed May 28, 2003 12:20 pm    Post subject: Reply with quote

For viewing the ouput of the process:

1.) logon (via ssh or similar)
2.) type:
Code:
nohup emerge kde &

3.) logoff
4.) do something else
5.) logon
6.) type:
Code:
tail -f nohup.out

7.) CTRL-C
8.) logoff
9.) repeat steps 5-8 as much as you want.
Back to top
View user's profile Send private message
chris84ae
n00b
n00b


Joined: 19 Apr 2003
Posts: 40

PostPosted: Fri Jun 06, 2003 7:00 am    Post subject: Reply with quote

if you just wont to view the output remotely and remain in control locally you can use tee

e.g.

emerge kde|tee output.log
you remian in control on the local screen
and you can tail output.log on a remote terminal
Back to top
View user's profile Send private message
viperlin
Veteran
Veteran


Joined: 15 Apr 2003
Posts: 1319
Location: UK

PostPosted: Wed Jun 18, 2003 9:16 pm    Post subject: Reply with quote

sometimes i let my friends ssh into my computer to either show them my latest script (my latest at this point being a script that perfectly imitates the trinity hack from the matrix reloaded, will be GPL and on my website soon)

last time after they looked @ my script. they ran "links" and started downloading pr0n pics to their account folder.

i need a way to simply snoop in on what they are doing (i own the host so i'm looking for a server side prog)

so i can maybe run "programname $username", e.g "sshwatcher chris" and it will show me what he's doing as if i was looking over his shoulder.


any idea's, i can't find anything in the portage tree.
Back to top
View user's profile Send private message
Lightspeed
n00b
n00b


Joined: 21 Feb 2003
Posts: 57
Location: UK

PostPosted: Wed Jun 18, 2003 10:46 pm    Post subject: Reply with quote

jkcunningham wrote:
If you are really opposed to screen, there is another way: ssh into the remote machine and launch it via the ssh window. Then its right there for you to watch. Of course, if you move to the remote terminal, so that its local, you won't be able to see it anymore. Just a thought.

-Jeff


You could always run the above mentioned ssh connection inside screen. Then if you want to go back to the machine the app is actually running on (or any other computer, for that matter) and still access the app you can setup another ssh connection to the previous computer and attach to the screen session. This will then work for installs from a live cd which has ssh but not screen installed.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum