Created
November 20, 2018 01:28
-
-
Save marco-ostaska/74efd34f51f62d311db4960ab8d3b7c1 to your computer and use it in GitHub Desktop.
Get ITM6 teps last login from TEPS Db2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ksh | |
. ~dbuser/sqllib/db2profile | |
db2 connect to TEPS | |
db2 "export to /tmp/users.del of del modified by chardel'' coldel@ decpt, select ID,NAME,LSTDATE from KFWUSER" | |
sed s/\'//g /tmp/users.del > /tmp/usersFMT.del | |
rm -f /tmp/users.del | |
HOSTNAME=`hostname` | |
echo "hostname,user ID, user name, last login mm-dd-yyy hh:mm:ss" > /tmp/lastlogin.csv | |
while read line | |
do | |
userid=`echo "$line" | cut -d@ -f1` | |
fullname=`echo "$line" | cut -d@ -f2` | |
DATE=`echo "$line" | cut -d@ -f3` | |
YY=`echo "$DATE" | cut -c2-3` | |
MM=`echo "$DATE" | cut -c4-5` | |
MMM=`date -d "$MM" "+%B"` | |
DD=`echo "$DATE" | cut -c6-7` | |
HH=`echo "$DATE" | cut -c8-9` | |
mm=`echo "$DATE" | cut -c10-11` | |
SS=`echo "$DATE" | cut -c12-13` | |
echo "$HOSTNAME,$userid,$fullname,$MMM/$DD/20$YY $HH:$mm:$SS" >> /tmp/lastlogin.csv | |
done < /tmp/usersFMT.del | |
rm -rf /tmp/usersFMT.del |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment