1833433 Members
2938 Online
110052 Solutions
New Discussion

Tracking user keystrokes

 
SOLVED
Go to solution
Ihab Zaki
Advisor

Tracking user keystrokes

I need to track users commands or keystrokes, have been surfing the forum and found that histroy file can be set as the following line in the .profile of each user:
HISTFILE=${HOME}/.history_files/.hist.`who am i|awk '{print $1}'`.$$.`date +%d%m%y.%H%M`

I found this lines works prfect when doing su - userid, or when connecting via telnet.
But when using reflectionX, and CDE it doesn't seem to recognise this line.

I tried to do it as the following:
export export HISTFILE=${HOME}/.history_files/.hist.`who am i|awk '{print $1}'`.$$.`date +%d%m%y.%H%M`

By doing so variable HISTFILE is declared but the `who am i|awk '{print $1}'` is not recognized and just contains nothing.

Any help will be much appreciatable.
Ihab
11 REPLIES 11
T G Manikandan
Honored Contributor

Re: Tracking user keystrokes

Edit $HOME/.dtprofile

Uncomment or change it to
DTSOURCEPROFILE=true


Thanks
Ihab Zaki
Advisor

Re: Tracking user keystrokes

T G, thanks for your fast reply,
but DTSOURCEPROFILE=true is already uncommented
Michael Steele_2
Honored Contributor

Re: Tracking user keystrokes

The correct command to use is 'script /dir/file'. Where /dir/file becomes the collection of all STDIN, STDERR and STDOUT data. This is keystrokes and their displayed results including any errors. Again:

script /dir/file
Support Fatherhood - Stop Family Law
T G Manikandan
Honored Contributor

Re: Tracking user keystrokes

Make sure the permissions are 755.


$chmod 755 $HOME/.dtprofile

Revert
Ihab Zaki
Advisor

Re: Tracking user keystrokes

T G,

I don't think there is a problem with .dtprofile
in the .profile I have 2 senarios first when I set histfile to
export HISTFILE=${HOME}/.history_files/.hist.`who am i|awk '{print $1}'`.$$.`date +%d%m%y.%H%M`

the HISTFILE is /home/.histroy_files/.hist..pid#.ddmmyy.hhmm
So it's just totally ignores the 'who am i part'

If I omit 'export'
the variable "HISTFILE" doesn't have a value, but I am sure the the .profile is executed in both cases.
Umapathy S
Honored Contributor

Re: Tracking user keystrokes

Ihab,
If you are using ksh, try exporting those values in .kshrc inside the home dir. If not found create the file.

You are talking about tracking users commands. If you really want to tract each and every keystroke the user makes, the best option is script. man script for more details.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Anonymous
Not applicable

Re: Tracking user keystrokes

You may want to
1) try $LOGNAME instead of

`who am i|awk '{print $1}'`

2) assign points :) in order to indicate how useful an answer was to you.
Ihab Zaki
Advisor

Re: Tracking user keystrokes

LOGNAME is changed every time you su to other users.
'who am i' is always the original user no matter who is the user that you su'ed to.
Steven E. Protter
Exalted Contributor

Re: Tracking user keystrokes

su -

loads the environment of the target username.

su does not load the environment.

For keystroke collection to work in CDE you must do a login as that user, not root with an su -

An su - in CDE will load the .profile for that user.

The data you have collected from who am i is correct but does not effect the outcome.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Alex Glennie
Honored Contributor
Solution

Re: Tracking user keystrokes

under $HOME vi .Xdefaults

add resource :

Dtterm*loginShell:True

log out and back in and test.

by default the .profile is not executed under a dtterm you could also try firing up a dtterm with the -ls option ?
Ihab Zaki
Advisor

Re: Tracking user keystrokes

Alex,

You almost found it, I added resource
*loginShell: True
Which this way can apply to all term types
And that sorted out the problem.
Thanks.
I would like to thank every person contribued to the problem.

THanks Again,
Ihab