Guest User

Untitled

a guest
Nov 25th, 2018
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #!/bin/ksh
  2.  
  3.  
  4. #HOSTS format:
  5. HOSTS="xxxx.xxx.xxx.xx-ACCOUNT"
  6.  
  7. FILE=/home/angela/list.txt #list will be saved on list.txt
  8.  
  9. date > $FILE
  10. echo >> $FILE
  11.  
  12. for host in $HOSTS; do
  13. ip=$(echo $host|cut -d '-' -f 1)
  14. title=$(echo $host|cut -d '-' -f 2)
  15. lsuser -a login ALL | grep '=true$' | awk '{ print $1 }' >/tmp/delta 2>/dev/null
  16.  
  17. echo "$title instance" >> $FILE
  18. perl -e 'print "=" x 65,"n"' >>$FILE
  19.  
  20. #we filter through unwanteduser.list to remove unwanted users
  21.  
  22. cat /tmp/delta|grep -wvf /home/angela/unwanteduser.list|sort >> $FILE
  23. echo >> $FILE
  24. done
  25.  
  26. rm -f /tmp/delta
  27.  
  28.  
  29. mailx -r From-account-server-no-reply@xyz.com -s "List of active Users and Locked users" angela@xyz.com < "$FILE"
  30.  
  31. Wed Oct 21 10:36:51 CDT 2015
  32.  
  33. Account instance
  34. =================================================================
  35. john
  36. alex
  37. raven
  38. max
  39.  
  40. Wed Oct 21 10:36:51 CDT 2015
  41.  
  42. list of Active users
  43.  
  44. Account instance
  45. =================================================================
  46.  
  47. john
  48. alex
  49. raven
  50. max
  51.  
  52. list of Locked users
  53.  
  54. Account instance
  55. =================================================================
  56. joe
  57. tracy
  58. karen
  59. ben
  60.  
  61. #!/bin/ksh
  62.  
  63.  
  64.  
  65. (
  66. date
  67. echo
  68. for host in $HOSTS; do
  69. echo "${host/*-} instance"cat
  70. perl -e 'print "=" x 65,"n"'
  71. lsuser -a login ALL | awk '/=true$/ { print $1 }' | grep -wvf /home/angela/unwanted.list
  72. lsuser -a login ALL | awk '/=false$/ { print $1 }' | grep -wvf /home/angela/unwanted.list
  73. echo
  74. done
  75. ) | mailx -r From-account-server-no-reply@xyz.com -s "List of active Users and Locked users" angela@xyz.com
  76.  
  77. (
  78. date
  79. echo
  80. for host in $HOSTS; do
  81. echo "${host/*-} instance"
  82. perl -e 'print "=" x 65,"n"
  83. lsuser -a login ALL | awk '/=true$/ { print $1 }' | grep -wvf /home/angela/unwanteduser.list
  84. echo
  85. done
  86. ) | 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