Looking at .sh_history file.


 
Thread Tools Search this Thread
Operating Systems AIX Looking at .sh_history file.
# 1  
Old 04-22-2011
Looking at .sh_history file.

I reviewed a couple old post where shockneck posted the use of the
Code:
EXTENDED_HISTORY=ON

variable to place a timestamp in the .sh_history file when using ksh and using the
Code:
fc -t

command to read the .sh_history file.

The fc command reads my history file. As an admin I would like to be able to read other users .sh_history file. In the past I have just copied it to a tmp location and read the file with my favorite editor. From what I can gather the timestamp is encrypted somehow so that I can't read it with a normal vi session.

Code:
ls -al /.sh_history #�#1303480405#�#
ls -al #�#1303480411#�#



Output using the fc command:

Code:
1113    2011/04/22 08:53:25 :: ls -al /.sh_history
1114    2011/04/22 08:53:31 :: ls -al



Is there a command out there that I can read the .sh_history file of other users and still be able to see the timestamp info?

If I am missing something obvious in the fc man page please just correct me.

Thanks.
# 2  
Old 04-22-2011
It doesn't look encrypted as such. That's the time in epoch seconds(1303480405 amounts to Fri Apr 22 07:53:25 CST 2011 in my timezone). I think it's just surrounded with that strange gobbedlygook to guarantee to ksh that it's looking at its OWN timestamps and not just some random comment that you typed into the shell by hand.

If you had GNU date getting real timestamps from epoch timestamps would be easy, but on AIX you might need to resort to perl.
Code:
#!/usr/bin/perl

while($line=<STDIN>)
{
        if($line =~ /^([^#]+)#...#([0-9]+)#...#\n/)
        {
                printf("%s\t%s\n", $1, localtime($2));
        }
        else
                print $line;
}

I wish I could test that regex, but that string is so weird it turns into nothing but ??????? when I copy-paste it.

Last edited by Corona688; 04-22-2011 at 12:01 PM..
# 3  
Old 04-22-2011
Right you are Corona688. Ok, easily decoded with a little scripting.

Anyone with knowledge of a command to just read the history file of another user without decoding please pass it along.

Thanks.
# 4  
Old 04-22-2011
how about cat?
# 5  
Old 04-22-2011
Maybe I misspoke, I meant read the history file of another user and the decoded timestamp be displayed rather than the epoch time as cat output looks just like the vi output.

Code:
ls -al /.sh_history #�#1303480405#�#
ls -al #�#1303480411#�#

For some reason I completely over looked your perl code above. I think I just read the email notice that came in and it didn't include all of your reply. Not a great coder but will see what I can make work.

Thanks again.
# 6  
Old 04-22-2011
I have a bad habit of editing my replies after I post them.

See?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies

2. AIX

Problem in Emailing all .sh_history entries

Hi, I can't get all the enties of AIX .sh_history in email. only first entry of the history is emailed after executing the below code. mail -s "History `date +%d-%m-%Y`" myemail@xyz.com <$HOME/.sh_history Can anyone help? (3 Replies)
Discussion started by: m_raheelahmed
3 Replies

3. UNIX for Advanced & Expert Users

sh_history file

Hi, I'm on a linux machine. But I see that sh_history is not updated since february 15. How is it possible ? Thank you. uname -a Linux MYSERVER 2.6.18-194.11.3.el5PAE #1 SMP Mon Aug 23 15:57:10 EDT 2010 i686 i686 i386 GNU/Linux ls -al -rw------- 1 oracle dba 3644 fév 15 09:28... (10 Replies)
Discussion started by: big123456
10 Replies

4. UNIX for Advanced & Expert Users

Incoherence between finger and .sh_history

Hello, I've a script that verifies users connections. This is the check part do NEVER=$(finger $USER | grep -i Never) if then NAME=$(finger $USER | grep -i "In real life" | sed -e 's/^.*life: //') echo $USER $NAME >> never_logged #" "$NEVER fi done that for a specific... (6 Replies)
Discussion started by: gogol_bordello
6 Replies

5. AIX

timestamp in .sh_history using ksh shell

Hello Everyone: Does anyone know how I will setup my account to put timestamp in my .sh_history? I do not hold the root account. I am using AIX 5 and ksh shell. I tried every solution I can find in the internet but nothing seems to work OR I am just applying those in the wrong way. Anyone knows... (4 Replies)
Discussion started by: Orbix
4 Replies

6. AIX

history .sh_history sh_history

hi what's the difference between .sh_history and sh_history for root user? thanks itik (1 Reply)
Discussion started by: itik
1 Replies

7. UNIX for Dummies Questions & Answers

Clarification on .cshrc,.exrc,.login,.profile,.sh_history files

All, I had a request to delete filed under a directory that was 35 days old . And they asked me to scedule it in CRON . I have done that . I have use find and delete with mtime to perfrom this task . But my script is not deleting this .cshrc,.exrc,.login,.profile,.sh_history file... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

8. UNIX for Advanced & Expert Users

.sh_history file

Hi Friends, We are currently 5 people using same Unix login-id on different terminals, .sh_history file contains list of commands typed by all 5 peoples(commands history) with the below list : $tail .sh_history ls -ltr pwd cd .. ls -ltr clear cd temp more kk.lst Now my question... (9 Replies)
Discussion started by: krishna
9 Replies

9. UNIX for Dummies Questions & Answers

.sh_history contains the list of past commands

hi, .sh_history keeps a list of past commands that we entered. but it has a limit and where do we set this limit. thanks. (1 Reply)
Discussion started by: yls177
1 Replies

10. UNIX for Dummies Questions & Answers

How to create .sh_history file

Thanks PxT answered my "compare two files"question very quick and neat!!:-) I have a question about .history file I couldn't find any satisfied answer from book. 1. This file was created automatically when you set up user's environment or you have to use a command to create it or you... (4 Replies)
Discussion started by: b5fnpct
4 Replies
Login or Register to Ask a Question