| Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-11-2012, 09:48 AM
|
#1
|
|
LQ Newbie
Registered: Aug 2011
Location: Bangalore
Posts: 16
Rep: 
|
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
|
|
|
|
06-11-2012, 11:02 AM
|
#2
|
|
Senior Member
Registered: Apr 2007
Location: bbsr,orissa,India
Distribution: RHEL5 ,RHEL4,CENT OS5,FEDORA,
Posts: 1,261
Rep: 
|
Quote:
Originally Posted by kalpeer
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.
|
06-12-2012, 12:27 PM
|
#3
|
|
Moderator
Registered: May 2001
Posts: 24,828
|
Quote:
Originally Posted by kalpeer
I want to capture all the operations performed in the terminal.
|
Have a look here?
|
|
|
|
06-12-2012, 01:40 PM
|
#4
|
|
LQ Newbie
Registered: Aug 2011
Location: Bangalore
Posts: 16
Original Poster
Rep: 
|
Quote:
Originally Posted by divyashree
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
|
|
|
|
|
06-16-2012, 03:54 AM
|
#5
|
|
Moderator
Registered: May 2001
Posts: 24,828
|
Quote:
Originally Posted by kalpeer
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:37 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|