Operating System - HP-UX
1834849 Members
2126 Online
110070 Solutions
New Discussion

How do I identify/summarize active/inactive users?

 
SOLVED
Go to solution
Stuart Abramson_2
Honored Contributor

How do I identify/summarize active/inactive users?

hpux-admins:

We are moving one old server's users and applications to another old server, to consolidate them on one server.

How do I find out who uses the old system and who doesn't.

I wrote a little script to "finger" each name in /etc/passwd:

awk -F: '{print $1}' passwd | while read USER
do
finger $USER
done

but it just spits out raw info:

Login name: lwwajeg In real life: Joe Gagor
Bldg: LPD Shippin
Directory: /home/lwwajeg Shell: /usr/bin/ksh
Last login Fri Jul 5, 2002 on ttypd
No Plan.

Login name: wiwakn In real life: Kumar Natarajan
Directory: /home/wiwakn Shell: /usr/bin/ksh
Never logged in.
No Plan.

Login name: a334hep
Directory: /home/a334hep Shell: /usr/bin/ksh
Last login Fri Aug 8 07:20 on ttypb
No Plan.

Can I summarize that somehow with "awk"?

What I want is something like, all on one line:

username home directory Last login

Stuart
7 REPLIES 7
Mark Greene_1
Honored Contributor

Re: How do I identify/summarize active/inactive users?

See the man pages for last and wtmp

mark
the future will be a lot like now, only later
James R. Ferguson
Acclaimed Contributor

Re: How do I identify/summarize active/inactive users?

Hi Stuart:

Since 'finger' yields information, you have a 'var'adm'wtmp' file of last logins. A one-line summary analysis of last logings can be obtained with 'last'. See the man pages for more information.

# last

# last jrf #...look specifically for user 'jrf'

Regards!

...JRF...
John Meissner
Esteemed Contributor

Re: How do I identify/summarize active/inactive users?

you can use this script:

All paths lead to destiny
John Meissner
Esteemed Contributor

Re: How do I identify/summarize active/inactive users?

you can use this script:

All paths lead to destiny
Kent Ostby
Honored Contributor
Solution

Re: How do I identify/summarize active/inactive users?

Stuart --

Output your finger data to : users.raw
Add this line to your script as well:
awk -f formatu.awk < users.raw > users.report

vi a file called formatu.awk in whatever directory you are working and cut and paste the following awk script:

/^Login / {daname=$3;next}
/^Directory/ {dadir=$2;next}
/^Never / {dalast="Never"
printf("%-9s %-40s %-s \n", daname, dadir, dalast);
next}
/^Last login/ {dalast=$3" "$4" "$5" "$6;
printf("%-9s %-40s %-s \n", daname, dadir, dalast);
next}
Double check to make sure that the full printf lines are on one line in the file and that should do it.


"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Con O'Kelly
Honored Contributor

Re: How do I identify/summarize active/inactive users?

Hi Stuart

# finger -s
This gives you a summarised version & puts everything on one line.

One other point is that often wmtp files are cycled, This can mean finger is unable to get any info on a particular user if that user has not logged in since the wtmp file was cycled.
If you have a trusted system /usr/lbin/getprpw gives more reliable "login" information (look for "slogint" & "ulogint").
Unfortunately its a bit messing extracting the info you want.

Cheers
Con
Doug Burton
Respected Contributor

Re: How do I identify/summarize active/inactive users?

Stuart,

I hope this helps. Final output goes into the /tmp/UserStatus file.