1845041 Members
2370 Online
110233 Solutions
New Discussion

Re: Who command problem

 

Who command problem

Hi all,

we used to manage user maximum sessions allowed by using "who command".

Some of our users .profile scripts manage user sessions with a command line similar to this atached:

taller='who|cut -c1-6|grep taller|wc -l'

We discover today that some user sessions are not reported by who command... i.e. whe launched 3 taller user sessions and "who" reports only one line containing info about taller.

Can anyone help? This mechanism is working for a few years (5) without a problem.

HPUX version is 10.20.

Thanks.
5 REPLIES 5
AshishJain_USA
Frequent Advisor

Re: Who command problem

Some smart user may have manipulated their .profile file.

Re: Who command problem

.profile is ok without manupulations.

Thank you
A. Clay Stephenson
Acclaimed Contributor

Re: Who command problem

Your utmp and/or wtmp files are probably corrupt. You could try to export/import them using fwtmp and clean them up or simply null the files. Man fwtmp for details.
If it ain't broke, I can fix that.
Geoff Wild
Honored Contributor

Re: Who command problem

Instead of cut, use awk

'who|awk '{print $1}'|grep taller|wc -l'


What about using last?

last |grep logged |grep taller |wc -l

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.

Re: Who command problem

Clay:

So I can reset utmp file with a simply echo > /etc/utmp?
From the moment utmp is null, who does not return any value until some user log into the system?

Geoff:

'who|awk '{print $1}'|grep taller|wc -l'

It won´t because who returns only a taler user line.

What about using last?
ast |grep logged |grep taller |wc -l

I guess it could work.

Thanks