Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/ksh
- #HOSTS format:
- HOSTS="xxxx.xxx.xxx.xx-ACCOUNT"
- FILE=/home/angela/list.txt #list will be saved on list.txt
- date > $FILE
- echo >> $FILE
- for host in $HOSTS; do
- ip=$(echo $host|cut -d '-' -f 1)
- title=$(echo $host|cut -d '-' -f 2)
- lsuser -a login ALL | grep '=true$' | awk '{ print $1 }' >/tmp/delta 2>/dev/null
- echo "$title instance" >> $FILE
- perl -e 'print "=" x 65,"n"' >>$FILE
- #we filter through unwanteduser.list to remove unwanted users
- cat /tmp/delta|grep -wvf /home/angela/unwanteduser.list|sort >> $FILE
- echo >> $FILE
- done
- rm -f /tmp/delta
- mailx -r From-account-server-no-reply@xyz.com -s "List of active Users and Locked users" angela@xyz.com < "$FILE"
- Wed Oct 21 10:36:51 CDT 2015
- Account instance
- =================================================================
- john
- alex
- raven
- max
- Wed Oct 21 10:36:51 CDT 2015
- list of Active users
- Account instance
- =================================================================
- john
- alex
- raven
- max
- list of Locked users
- Account instance
- =================================================================
- joe
- tracy
- karen
- ben
- #!/bin/ksh
- (
- date
- echo
- for host in $HOSTS; do
- echo "${host/*-} instance"cat
- perl -e 'print "=" x 65,"n"'
- lsuser -a login ALL | awk '/=true$/ { print $1 }' | grep -wvf /home/angela/unwanted.list
- lsuser -a login ALL | awk '/=false$/ { print $1 }' | grep -wvf /home/angela/unwanted.list
- echo
- done
- ) | mailx -r From-account-server-no-reply@xyz.com -s "List of active Users and Locked users" angela@xyz.com
- (
- date
- echo
- for host in $HOSTS; do
- echo "${host/*-} instance"
- perl -e 'print "=" x 65,"n"
- lsuser -a login ALL | awk '/=true$/ { print $1 }' | grep -wvf /home/angela/unwanteduser.list
- echo
- done
- ) | mailx -r From-account-server-no-reply@xyz.com -s "List of active Users and Locked users" angela@xyz.com
Add Comment
Please, Sign In to add comment