Operating System - HP-UX
1751811 Members
5295 Online
108781 Solutions
New Discussion юеВ

How can I log the command entered

 
Oscar Koay
New Member

How can I log the command entered

I am looking forward to log the commands that I have type on the shell into a log file, so that I can review what I had been done for that particular session. Like a trace back for me.

Thank you.
Freshman in Unix World
6 REPLIES 6
Pramod_4
Trusted Contributor

Re: How can I log the command entered

Hi,

Consider using history option in K shell if you just want to log the commands used.

U can use the command "script" to log the enitre session which includes in/out and errors.

Regards,
Pramod
Madhu Sudhan_1
Respected Contributor

Re: How can I log the command entered

Oscar Koay :

Add the following in your .profile.

See the attachment.
Ensure your filesystem has long filenames enabled.
Think Positive
Mike Stroyan
Honored Contributor

Re: How can I log the command entered

You can log all that you enter and the responses by using the "script" command. It will launch a new shell under a new pty and record all tty output in a file.
http://devresource.hp.com/STK/man/11.00/script_1.html
JACQUET
Frequent Advisor

Re: How can I log the command entered

Hi,

For "logging" all entries and commands from a shell, you could add in your shells lines like this (in ksh):

LOG=/tmp/log.txt
set -xv
exec 1>> $LOG 2>&1
PJA
f. halili
Trusted Contributor

Re: How can I log the command entered

1. You may check your .sh_history file if you are using korn shell.

2. You may also use "/usr/sbin/script"
# script -a my_tracefile
derekh
Shannon Petry
Honored Contributor

Re: How can I log the command entered

Boy, all these remarks on Korn shell make it appear that it's the only shell supporting history... : (
In all shells, a history variable set to a number means to record that many commands. The histfile variable controlls where the file is located.
I.E.
BASH and KSH
>HISTORY=1024
>HISTFILE=$HOME/.history
CSH
>set HISTORY=1024
>set HISTFILE=$HOME/.history
For the fancy that want to save commands, use
HISTFILE=$HOME/.history-`date %d-m-%y`.

I agree that though that the script command is probably what you want, however note that the script command is very litteral. All garbage, typo's, etc are there. Be prepared to se ps -ef }^H^H| grep ls ^M, etc.....

Best regards,
Shannon
Microsoft. When do you want a virus today?