wagoneers.com



In trying to determine which users have logged into my system I attemped
to use "uniq" to break down the list from "last".  However, it's not
as easy as I thought... :)  It seems that uniq doesn't work properly, or
because I'm an idiot, I'm not using it properly.  :)

The goal is to reduce the output from last to a single line of
user information.  So far the following is true:

if I do a "last | wc -l", I get 119 occurrences on a particular system.
if I do a "last | grep -v root | wc -l", I get 88 occurrences.
if I do a "last | uniq -d | wc -l", I get 0.   (???)
if I do a "last | awk '{print $1}' | grep -v root | wc -l", I get 88.

and then, if I do:

 

last | awk '{print $1}' | grep -v root | uniq -d | wc -l

I get 12... with 10 of those being duplicates, and another 2, one of those being a duplicate. THEN, if I do:

last | awk '{print $1}' | grep -v root | grep -v reboot | uniq -d | wc -l

and didn't get the same answer!!! so much for a "uniq" afternoon.... :) It's close enough for what I'm looking for though... wait... I'll try using it with sort...

last | awk '{print $1}' | grep -v root | grep -v reboot | sort | uniq -d

AHA!, it works, while the other "uniq" without "sort" doesn't, see: >--> last | awk '{print $1}' | grep -v root | grep -v reboot | uniq -d jxxxxxx jxxxxxx ----------------------------------------------------- root@wxxxxxxx [/root] >--> last | awk '{print $1}' | grep -v root | grep -v reboot | sort | uniq -d cxxxxxxx jxxxxxxx so, now I can take this string and run it through my for loop and remotely check each workstation for user id so I can update my password file with only those users that have accessed my systems. :) #!/bin/sh # # 99dec17 - get user names from last # echo " executing script to determine users on all HP engineering workstations " for x in `cat /raid/02d/sa/rem/hostseng` do echo $x >> /raid/02d/sa/rem/log.`/usr/bin/date +%y%b%d`.users echo " ================== " >> /raid/02d/sa/rem/log.`/usr/bin/date +%y%b%d`.users echo $x remsh $x last | awk '{print $1}' | grep -v root | grep -v reboot | sort | uniq -d \ | tee -a /raid/02d/sa/rem/log.`/usr/bin/date +%y%b%d`.users echo " ================== " echo " ================== " >> /raid/02d/sa/rem/log.`/usr/bin/date +%y%b%d`.users done echo " completed list, results found in /raid/02d/sa/rem/log.`/usr/bin/date +%y%b%d`.users "


wagoneers.com




Select pages from WAGONEERS.COM: 

the Full Size Jeep decal! © 1998-2000 John Meister
Buy this FSJ decal...   ...use PayPal to pay for it!
Make payments with PayPal, or sign up here!


a viable option to bloated and unstable code


AMSOIL synthetic lubricants and filters
(please use customer #283461)

Independent Lifetime Dealer John Meister - customer #283461 - since 1983


Shop AMAZON.com from wagoneers.com! 
Search:
Keywords:
SHOP from wagoneers.com: in Association with Amazon.com



these pages protected by US Copyright laws
John Meister copyright © 1995-2001 all rights reserved
contact john-at-wagoneers.com
"Join the fight against spam (UCE)! Eliminate spam!" Washington State has a $500 fine for "spam"
(unsolicited commercial email)!


this is an approved Family-Friendly Site       read the Bible