Simple Script question

I am trying to gather a report on service accounts. The report needs the account and the last time they changed there passwords date (Lastupdate). I have been doing this one by one and wondering if there is a simple for loop to gather all the information. your help is greatly appreciated.

how you are doing manually ?

post the commands which you use to gather the report

pwdadm -q Username | grep lastupdate

[once i have this i then convert using]

perl -le 'print scalar localtime shift' 

In fact you do quite the same in a script. The following is a sketch which can perhaps be refined once we know a bit more about your environment, but it is a place to start. Save the following to a file (replace "<spc>" and "<tab>" with literal space/tab characters) and call it by "/path/to/script /path/to/inputfile":

#! /bin/ksh
# This script reads a list of usernames from a file and applies your command

typeset fIn="$1"
typeset chUser=""

cat "$fIn" | sed 's/#.*$//;s/^[<spc><tab>][<spc><tab>]*//;s/[<spc><tab>][<spc><tab>]*$//;/^$/d' |\
while read chUser ; do
     pwdadm -q "$chUser" | grep lastupdate | perl -le 'print scalar localtime shift'
done

exit 0

The input file should have one username in a line, comments and empty lines are possible. The sed-command just filters out white space and these comments, the rest is straight-forward.

I hope this helps.

bakunin

Thank you for your reply.
I actually received some help from a co-worker. here is what i did-
1) created a file on each server called service accounts
2) added a list of accounts we wanted to report on in the service account file
3) coworker wrote a script
4) I ran the script from the NIM server.

for host in $(cat /home/user); do ssh $host 'hostname 1>&2; for user in $(cat /home/user/service_account); do sudo lsuser -a lastupdate $user | grep lastupdate; done'; done | perl -MPOSIX -e 'while (<STDIN>) { $_ =~ "^([^=]*)=(.*)\$"; print $1; print strftime(" %a %b %e %H:%M:%S %Y\n", localtime($2)); };'