Skip to contentSkip to conversation

Starting "Script" when user logs on.

DISCUSSION Md Shanto 6 participants 6 messages Aug 3, 2005 – Aug 4, 2005

lore
Share & tools
lore

Md Shanto

author
#0 lore raw

Hi all,

I am trying to force "script" for logging all text I/O activities at the moment user logs in. Most of the users are running bash at this moment.

Initially I tired with "ttyrec" a tty recorder and failed, as it says "Out of pty's - Terminated". Now, I tried something like below:

------------------
#!/bin/bash -l
USER=whoami
LOGTIME=date +%Y-%m-%d-%H:%M:%S /usr/bin/script -q /var/log/commlog/$USER-$LOGTIME
------------------

and assigning this script in /etc/passws. This script will log scripts with time stamp in /var/log/commlog/.

what happen is: when user logs in the process becomes a loop and I see lot of script instances are running.

Any idea.

-Refayet

#1 lore raw

I don't think script will help you, as even if you get it working, your users can just Ctrl-D out of it. Unless you trust your users. Once upon a time I used ttysnoop:
http://freshmeat.net/projects/ttysnoop/

Quoted 34 lines · Md Shanto

Hi all,

I am trying to force "script" for logging all text I/O activities at the moment user logs in. Most of the users are running bash at this moment.

Initially I tired with "ttyrec" a tty recorder and failed, as it says "Out of pty's - Terminated". Now, I tried something like below:

------------------
#!/bin/bash -l
USER=whoami
LOGTIME=date +%Y-%m-%d-%H:%M:%S /usr/bin/script -q /var/log/commlog/$USER-$LOGTIME
------------------

and assigning this script in /etc/passws. This script will log scripts
with time stamp in /var/log/commlog/.

what happen is: when user logs in the process becomes a loop and I see
lot of script instances are running.

Any idea.

(quoted diff) +0 -2
-Refayet
-

To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 1 line · urgrue

I don't think script will help you, as even if you get it working, your users can just Ctrl-D out of it. Unless you trust your users.

Unless you can get this script running as some kind of wrapper to bash.
Then you can change the default shell for your users to point at this
wrapper ..

-a

Signature · 2 lines
Regards, Andy Davidson
http://www.fotoserve.com/ - Great deals on digital imaging output.
#3 lore raw

use screen to start their shell and turn on logging in screen.

Signature · 3 lines
Jason
The place where you made your stand never mattered. Only that you were there..
And still on your feet.
Quoted 8 lines · Andy Davidson
Quoted 2 lines · urgrue

I don't think script will help you, as even if you get it working, your users can just Ctrl-D out of it. Unless you trust your users.

Unless you can get this script running as some kind of wrapper to bash. Then you can change the default shell for your users to point at this wrapper ..

-a

#5 lore raw
In reply to Md Shanto
Quoted 2 lines · Md Shanto

Initially I tired with "ttyrec" a tty recorder and failed, as it says "Out of pty's - Terminated".

Unless these processes aren't being cleaned up (in which case, you will probably have over a hundred stale ttyrec processes), it may be that ttyrec was compiled for BSD-style ptys but your system is using Unix98 ptys (or vice-versa).

Quoted 8 lines

Now, I tried something like below:

------------------
#!/bin/bash -l
USER=whoami
LOGTIME=date +%Y-%m-%d-%H:%M:%S /usr/bin/script -q /var/log/commlog/$USER-$LOGTIME
------------------

Apart from anything else, you should probably use "exec" for the last statement, i.e.:

exec /usr/bin/script -q /var/log/commlog/$USER-$LOGTIME

This causes the "script" process to replace the bash process running the shell script, rather than leaving the bash process hanging around until script exits.

#4 lore raw
In reply to urgrue
Quoted 15 lines · urgrue <urgrue <at> tumsan.fi> writes:

I don't think script will help you, as even if you get it working, your users can just Ctrl-D out of it. Unless you trust your users. Once upon a time I used ttysnoop:
http://freshmeat.net/projects/ttysnoop/

Quoted 8 lines · Md Shanto

Hi all,

I am trying to force "script" for logging all text I/O activities at the moment user logs in. Most of the users are running bash at this moment.

Initially I tired with "ttyrec" a tty recorder and failed, as it says "Out of pty's - Terminated". Now, I tried something like below:

[...]

Quoted 6 lines
Quoted 6 lines

and assigning this script in /etc/passws. This script will log scripts
with time stamp in /var/log/commlog/.

what happen is: when user logs in the process becomes a loop and I see lot of script instances are running.

I think (not sure) that script also tries to start the default shell for the user and calling the script in the process...

Perhaps you could try a line like:
/path/to/script ; exit
at the end of your /etc/profile?

Not sure if it'll work, though.

HTH, HAND

mvg,
Guus