LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 06-11-2012, 09:48 AM   #1
kalpeer
LQ Newbie
 
Registered: Aug 2011
Location: Bangalore
Posts: 16

Rep: Reputation: Disabled
Thumbs up How to Capture a Unix Terminal Session?


Hi All,

I want to capture all the operations performed in the terminal. So to achieve this I used “script” command. This works as I expected. But this command captures all the standard output which is redirected to terminal. For example if i “tail” a file, even the tail output is getting captured. But I want to capture only the commands not the output. I don’t want to capture the Standard Output. Is there any way to capture only the commands that are typed in the terminal?

I don’t want use the bash history since it will not store TTY information. I have automated this process, whenever user logins a script will be started to capture the operations.

Thanks,
Kalai
 
Old 06-11-2012, 11:02 AM   #2
divyashree
Senior Member
 
Registered: Apr 2007
Location: bbsr,orissa,India
Distribution: RHEL5 ,RHEL4,CENT OS5,FEDORA,UBUNTU
Posts: 1,347

Rep: Reputation: 135Reputation: 135
Quote:
Originally Posted by kalpeer View Post
Hi All,

I want to capture all the operations performed in the terminal. So to achieve this I used “script” command. This works as I expected. But this command captures all the standard output which is redirected to terminal. For example if i “tail” a file, even the tail output is getting captured. But I want to capture only the commands not the output. I don’t want to capture the Standard Output. Is there any way to capture only the commands that are typed in the terminal?

I don’t want use the bash history since it will not store TTY information. I have automated this process, whenever user logins a script will be started to capture the operations.

Thanks,
Kalai
You can tweak the HISTFILE variable in user's rc/profile to save the command history on terminal number basis of each user.

Code:
TTY=$(tty | sed 's|/|_|g')
HISTFILE="~/.bash_history$TTY"
 
1 members found this post helpful.
Old 06-12-2012, 12:27 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,987
Blog Entries: 54

Rep: Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742
Quote:
Originally Posted by kalpeer View Post
I want to capture all the operations performed in the terminal.
Have a look here?
 
Old 06-12-2012, 01:40 PM   #4
kalpeer
LQ Newbie
 
Registered: Aug 2011
Location: Bangalore
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by divyashree View Post
You can tweak the HISTFILE variable in user's rc/profile to save the command history on terminal number basis of each user.

Code:
TTY=$(tty | sed 's|/|_|g')
HISTFILE="~/.bash_history$TTY"
Thanks a lot this helped me..
But in history file a date is getting updated along with each command. Is it possible to remove all other data except command.

Quote:
#13000123
ls
#13000124
cd /tmp
 
Old 06-16-2012, 03:54 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,987
Blog Entries: 54

Rep: Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742Reputation: 2742
Quote:
Originally Posted by kalpeer View Post
I don’t want use the bash history since it will not store TTY information.
One of the rules of safe(r) programming says you should never trust user-submitted input. So no, you should not trust or rely on settings or files if the user owns them and can modify them at will.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capture the telnet session output in file anirudha0012 Linux - Newbie 2 03-02-2012 12:16 AM
make commands keep running after leaving a terminal session or ssh session Danny3031 Programming 18 01-30-2012 11:29 AM
ipvsadm session packet capture zmunawar1 Linux - Server 0 07-13-2008 03:08 PM
Switching back to the Mandrake 9.1 desktop from terminal rdesktop terminal session marc218 Linux - General 6 02-08-2007 02:45 PM


All times are GMT -5. The time now is 07:04 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration