1834368 Members
2193 Online
110066 Solutions
New Discussion

Script help

 
SOLVED
Go to solution
Prashant Zanwar_4
Respected Contributor

Script help

I want to write a script which will tell me number of sessions open by users on a system. and I want to know top ten of them?
How to acheive this..

Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
5 REPLIES 5
RAC_1
Honored Contributor
Solution

Re: Script help

for i in 'logins -u|awk '{print $1}'`
do
count=`who -u|grep ${i} | awk '{print $1}'|wc -l`
user=`who -u|grep ${i} | awk '{print $1}'|uniq`

echo "${count} ${user}" >> /tmp/user-list
sort -rnk1 /tmp/user-list|head -10
done

Anil
There is no substitute to HARDWORK
H.Merijn Brand (procura
Honored Contributor

Re: Script help

# whodo

is also a nice - lesser known - command

Enjoy, Have FUN! H.Merijn [ who'd do it in perl with Proc::ProcessTable ]
Enjoy, Have FUN! H.Merijn
Prashant Zanwar_4
Respected Contributor

Re: Script help

Any way to acheive using perl..just curious.

Thanks a lot.

Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Prashant Zanwar_4
Respected Contributor

Re: Script help

Can someone please reply if this can be acheived using perl..

perl experts!

Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
H.Merijn Brand (procura
Honored Contributor

Re: Script help

Example of may (daily used) perl replacement for ps attached

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn