#!/bin/rc # # last login of user, # with an arg it prints only matching entries. # rfork e rd=cat if (! ~ $#* 0) rd=(grep ' ' ^$"*) cat /sys/log/auth | $rd | awk ' $5=="tr-ok" && $NF ~ ".*@bootes"{ uid = $NF; gsub("@.*$", "", uid); last[uid] = $2 " " $3 " " $4; gsub(":[0-9][0-9]$", "", last[uid]); ip = $6; gsub("^.*\\(", "", ip); gsub("\\).*$", "", ip); from[uid] = ip; } END{ cmd = "ls -ltu /usr/*/lib/profile"; while(cmd | getline){ uid = $NF; gsub("^.*/usr/", "", uid); gsub("/lib/profile$", "", uid); if(last[uid] == "") last[uid] = $7 " " $8 " " $9; } close(cmd); for(i in last) printf("%-20s %-16s %s\n", i, last[i], from[i]); } '