[Solved] Finger command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Finger command
# 1  
Old 02-16-2014
[Solved] Finger command

Hi,

I am writing script to take last logon user id detials by using finger command.

But I am getting below output.

wer34 Feb 10:23

I NEED to display

wer34 Feb 10 2013 10:23, Is there any way to get like this.
# 2  
Old 02-17-2014
As with ls -l, login time in finger output is month, day, and time if the login time is within six months of the current time; otherwise it is month, day, and year. So, if the year or time field contains a colon, you can figure out if the month and day shown are in the current year or the previous year an add it as needed. But, if the login time was more than 6 months ago, there is no way to get the login time unless your version of finger provides an option that allows you to override the default login time output format.
# 3  
Old 02-17-2014
Thanks Don.

I want to write report for last logon user detials.

Code:
The below user id wre34 is not an active user from Sep 2013. his last logon Aug 7 2013
 
Directory: /export/home/wre34           Shell: /bin/ksh
Last login Wed Aug  7, 2013 on pts/111
No unread mail
No Plan.
 
The other user id ivv41 las logon was Sep 21 2013
 
Directory: /export/home/ivv41           Shell: /bin/ksh
Last login Mon Sep 23 17:28 on pts/47 from remb02mkiwsf25
Mail last read Sat Sep 21 15:13:31 2013
No Plan
 
current usr id
 
Directory: /export/home/por12           Shell: /bin/ksh
On since Feb 17 15:26:40 on pts/75 
Mail last read Sat Feb  1 15:25:28 2014
No Plan.

If I use finger userid |grep On Since

I would get month date time and year but login time was more than 6 months ago will not display.
Moderator's Comments:
Mod Comment Please use CODE tags to mark sample input, sample output, and sample code. I have added CODE and ICODE tags to this post, but I am not at all sure that I put the CODE tags in the right spots. (I don't know if there should be one sample output or three sample outputs.

Last edited by Don Cragun; 02-17-2014 at 01:37 AM.. Reason: Add CODE tags.
# 4  
Old 02-17-2014
If you use finger userid |grep On Since you're likely to get a diagnostic message like:
Code:
grep: Since: No such file or directory

And since your output shows that the output from the lines you're trying to match doesn't have Since capitalized, even if you had quoted it correctly you still wouldn't get any output. Perhaps you meant:
Code:
finger <userid> | grep 'On since'

which could give you several lines of output for the specified user.

If someone's last login time was more than six months ago, why does it matter what time of day it was for a report like this?

For someone still logged in, unless you are keeping systems up for more than a year and a half without rebooting, the year should be obvious as long as the date the report was generated is included in the report.
# 5  
Old 02-17-2014
But I have requirment like the active user list last logon detials report, at lease need date,month and year
# 6  
Old 02-17-2014
So what have you tried to do to convert the time stamp into a year for login times that occur in the last six months?
This User Gave Thanks to Don Cragun For This Post:
# 7  
Old 02-17-2014
To get year thought of using
Code:
Last

command but it is taking from /wtmp directory. Also this folder get created every month on 1st date. So If I run last command it shows from Feb 1st 2014.

But I want all active user last logon detials with year


Example - If user logged on Dec 12 2013. If I run report today I wanna get O/P like

wre34 Dec 13 2013
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Not able to disable finger & telnet command in Solaris 8

Hi I need to disable finger & telnet command in solaris 8 I have put the # infront of finger and telnet line in /etc/inetd.conf file. Further I have run the below command kill -1 <process id of inetd > But when I am running finger command it is till giving information for remote machine... (8 Replies)
Discussion started by: amity
8 Replies

2. UNIX for Beginners Questions & Answers

Finger command and security issue

$ finger yeti Login: yeti Name: yeti Directory: /arpa/tz/y/yeti Shell: /bin/ksh On since Wed Apr 2 15:24 (UTC) on pts/149 Mail last read Mon Mar 31 11:08 2014 (UTC) No Plan. Hi there, I am trying to... (2 Replies)
Discussion started by: alvinoo
2 Replies

3. UNIX for Dummies Questions & Answers

Extracting specific info finger command

how to extract user machine name for current terminal using finger command below command gives machinename for all session , is it possible to filter it to only currernt terminal ? finger -b -p $LOGNAME | grep from (12 Replies)
Discussion started by: lalitpct
12 Replies

4. UNIX for Dummies Questions & Answers

Finger command help

Hi Does anyone know if there is anyway of doing the finger command for all user id's in my enviroment. What I need to obtain is the full names of all users on the system. I know if i do the finger command with no arguments it will list users currently logged in, but i need all users... ... (2 Replies)
Discussion started by: m3y
2 Replies

5. UNIX for Advanced & Expert Users

finger command

I want to know the correct version of how i should use the finger command in this example below.(os is debian lenny) (nymserver.pl is located in /home/nymserv directory.) the two versions are : (in/etc/inetd.conf) finger stream tcp nowait nymuser /usr/nym/nymserv nymserv... (3 Replies)
Discussion started by: xstation
3 Replies

6. UNIX for Dummies Questions & Answers

Extracting specific info from finger command

Hello all, my unix is bash based and the finger command output is: Login Name Tty Idle LoginTime Office amos.john Amos John pts/26 1 Dec 5 16:18 (77.100.22.07) What am trying to achieve is extract the Login (amos.john) and Name (Amos John) from this output without using awk or sed. ... (1 Reply)
Discussion started by: franny
1 Replies

7. Shell Programming and Scripting

help in finger command.

Hi, iam using sunsolaris. when you type finger command -- it dispalys information about local and remote users. but here it shows as can't stat /dev/gold:8664 can anybody help what is the solution for this error. previously the output came. thanks, shan (1 Reply)
Discussion started by: shanshine
1 Replies

8. UNIX for Advanced & Expert Users

finger command

Hello all, Here is what I am trying to do. If a user exist, then send an echo "EXIST" or else "DOES NOT EXIST". (under HP-UX) Kind of: #!/usr/bin/sh USER=mylogin finger $USER if $? = 0 then echo "EXIST"" else echo "DOES NOT EXIST" fi (10 Replies)
Discussion started by: qfwfq
10 Replies

9. Shell Programming and Scripting

How to input username on text file into finger command on shell script

I'm trying to clean up my server and I have the list of some "special" users stored on the text file like this Now I want to write a shell script to finger all of them so I can have some kind of ideas who they are but here comes the problem....I completely forgot how to do it with shell... (3 Replies)
Discussion started by: Micz
3 Replies

10. Shell Programming and Scripting

Using the Finger command in a Script

This is my senario..... The user enters a userid into linux. ((I have have already scripted the command to read this userid.)) I need help in writing the script so It reads the userID and in conjuction w/ the finger command displays to the user "no plan" on the screen (so the user reads/sees... (4 Replies)
Discussion started by: apolishuk
4 Replies
Login or Register to Ask a Question