Incoherence between finger and .sh_history


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Incoherence between finger and .sh_history
# 1  
Old 11-27-2009
Incoherence between finger and .sh_history

Hello,
I've a script that verifies users connections.
This is the check part

Code:
do
NEVER=$(finger $USER | grep -i Never)
 if [ "$NEVER" != "" ]
 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 user says me that he never connected on last 4 months :

Code:
wtmp begins Wed Jul  x xx:xx

and, as you can see, it seems to be correct :

Code:
SERVER$ finger user
Login name: user                     In real life: Name Surname
Directory: $USERHOME       Shell: /bin/ksh
Never logged in.
No unread mail
No Plan.

Well, the problem is that I know "user" is almost daily connected, as you can easily see from is .sh_history.

Code:
SERVER$ ls -la $USERHOME/.sh_history
-rw-------   1 user  groupe     111111 Nov 26 10:02

This is a diffuse problem. Anyone has suggestions?
Best Regards

Last edited by gogol_bordello; 11-27-2009 at 06:10 AM..
# 2  
Old 11-27-2009
Do you KNOW (first hand knowledge from obervation with truss/trace/opensource) what finger does - what files it reads - on your box?

What OS do you have?

My first guess is that there is a disconnect between finger's actual implementation and what you think it does.
# 3  
Old 11-29-2009
Finger reads "wtmp". If wtmp does not exist, or is empty, or has wrong permissions, finger will return "Never logged in".


What does this give?


Code:
last -R username


Last edited by methyl; 11-29-2009 at 09:29 PM.. Reason: Weird display corruption
# 4  
Old 11-30-2009
@jim mcnamara
I supposed the same... but I don't find any trace :-/

Code:
munmap(0xEF750000, 8192)                        = 0
open("/etc/passwd", O_RDONLY)                   = 3
open("/var/adm/lastlog", O_RDONLY)              = 4
open("/var/adm/utmpx", O_RDWR|O_CREAT, 0644)    Err#13 EACCES
open("/var/adm/utmpx", O_RDONLY)                = 6
open("/var/adm/utmpx", O_RDONLY)                = 7
access("/var/adm/utmp", 0)

SunOs 5.6

---
@methyl
no -R option for last
Code:
-rw-r--r--   1 root     group  33654 Nov 30 09:54 wtmp
-rw-r--r--   1 root     group  894587 Nov 30 09:54 wtmpx

/here/i/am% last $USER

wtmp begins Wed Jul  x xx:xx

# 5  
Old 12-01-2009
methyl - I have not seen a POSIX specification for finger stating that it reads any given file. However, it does read other accounting files. See above. On Solaris, finger reads /var/adm/utmpx. Read the man page.


Gogol - It looks like wtmp is being updated. last should work as methyl indicated but without the -R. There are also wtmpx entries on your system. wtmp is written to only if the file exists, and for you is not part of the picture for finger.
what does
Code:
ls -l /var/adm/utmp

show?

if you grep for your username in umtpx what do you get? -- if it works you will see a lot of garbage characters. If they trash the screen use the reset command.
# 6  
Old 12-01-2009
finger is ready to try to match stuff in the gecos field and it marches to its own beat with respect to user names. You have concealed the user's real name and that is probably what is wrong. Is the is user name a mix of 8 characters or less of all lower case letters or digits?
# 7  
Old 12-10-2009
Looked more closely at the original post. Could multiple matches with text in the password file.

Preferable syntax makes an exact match on the username.

Quote:
finger -m "${USER}"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. AIX

Looking at .sh_history file.

I reviewed a couple old post where shockneck posted the use of the EXTENDED_HISTORY=ON variable to place a timestamp in the .sh_history file when using ksh and using the 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... (5 Replies)
Discussion started by: juredd1
5 Replies

4. 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

5. 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

6. 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

7. 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

8. 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

9. UNIX for Dummies Questions & Answers

finger

is there a way to show information on all the users on your system? when i use 'finger' is only shows users names and info who are currently on the system. is there a way to show all accounts? thanx! (5 Replies)
Discussion started by: djatwork
5 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