1836999 Members
2696 Online
110111 Solutions
New Discussion

recording a session

 
SOLVED
Go to solution
Shivkumar
Super Advisor

recording a session

Dear Sirs;

Is there any command or way to record the command line session and its output in some file ?

Thanks,
Shiv
13 REPLIES 13
Thayanidhi
Honored Contributor
Solution

Re: recording a session

Hi,

script

After you complete, simply type exit.

never cat that file or vi during session, which will make a loop!!

Regds
TT
Note: Only echoed charactors are stored here, no need to worry about passwords entered during the session.
Attitude (not aptitude) determines altitude.
Hakan Aribas
Valued Contributor

Re: recording a session

If you use CRT or SecureCRT (or a similar program), you can use "log session" option to save entire session. There is an example in the attached JPEG file.
VIKAS AGRAWAL
Frequent Advisor

Re: recording a session

HI Shiv ,

u can use KT , Xterm or even hyper terminal or any other external software to save your session it u are doing telnet from outside .

If u r doing it from a terminal then u can use script XYZ command to write all your command & output to XYZ file .

Hope this should solve
Raj D.
Honored Contributor

Re: recording a session

Hi Shiv ,

1.
You can use Putty , a ssh client , which is a very good tool , and you can save entire session to a logfile , Just only thing needs to do is to enable logging , and provide a file name :

Example: Enable logging and provide logfile name: server3.log And all will be there , including your command output.

Here it is :
http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe

2. $HOME/.sh_history you can set the history size to big enough.

Cheeers,

Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Devender Khatana
Honored Contributor

Re: recording a session

Hi,

The simplest way would be to export history of all users to seperate files. It can be achived by adding this line to /etc/profile for all users or .profile of indivisual users for which you intend to do this.

export HISTFILE="/var/log/history/$LOGNAME"
export HISTSIZE=1000

Also create the directory /var/log/history and seperate files for all users under it with write permissions for them.

HTH,
Devender
Impossible itself mentions "I m possible"
Mel Burslan
Honored Contributor

Re: recording a session

Connecting this question with another one you asked recently, powerbroker gives you this functionality, logging screen output along with the keystrokes in a local or remote log file.
________________________________
UNIX because I majored in cryptology...
Sandman!
Honored Contributor

Re: recording a session

It depends on the kind of session logging you want? For generic and simple usage I would prefer script as it's available on all Unix systems.

regards!
Arunvijai_4
Honored Contributor

Re: recording a session

Putty provides better logging capabilities for SSH and Telnet. But, it will be on the client side. If you want to have record at the server side, you can set HISTORY and HISTFILE in your shell.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Joseph Loo
Honored Contributor

Re: recording a session

hi shiv,

i can only think of script command for your requirement.

man script for more detail.

from the client, i use secure shell which log session of commands and outputs.

http://www.ssh.com

regards.
what you do not see does not mean you should not believe
Vibhor Kumar Agarwal
Esteemed Contributor

Re: recording a session

I'll say go by the script command because with History option you will have to supply the size and if the file increases you will lose the older data.
Vibhor Kumar Agarwal
Muthukumar_5
Honored Contributor

Re: recording a session

When You want to record command line information only then setup history setting as,

--- /etc/profile ---

set -o vi
export HISTFILE=/tmp/history_${LOGNAME}_$(date +'%d-%m-%y')
export HISTSIZE=2000

If you want to log all command execution and results then,

--- /etc/profile ---
script -a

You can also enable logging with putty and login client tools also.

hth.
Easy to suggest when don't know about the problem!
Cem Tugrul
Esteemed Contributor

Re: recording a session

Shiv,

i think We have some different solutions
through your Q.
if you want this permanently then history&histfile as the other members mentioned would be solution...
Also you have chance to record your session
as using your telnet software like crt&putty
etc...
there is also "script" on unix so when you
open session before starting just write
script so system records your executed commands into a file and when you exit the file closed and you can also put this command any user's profile and get these records...

Goos Luck,
Our greatest duty in this life is to help others. And please, if you can't
Cem Tugrul
Esteemed Contributor

Re: recording a session

"script" is a ux command...
Good Luck,
Our greatest duty in this life is to help others. And please, if you can't