Hi Folks,
Today I finished creating customization script to one of the customer. The objective to create this customization script is to deliver the report immediately to customer since they do not have this kind of delivery report in current system. Take a look and let me know if you have any questions.
#!/bin/sh
export dir=/var/lib/mysql/MT-Support
export script=/var/lib/mysql/MT-Support/scripts
export log=/var/lib/mysql/MT-Support/log
export in=/var/lib/mysql/MT-Support/in
export out=/var/lib/mysql/MT-Support/out
DateTime=`date +%Y-%m-%d-%H-%M-%S`
Date=`date +%Y-%m-%d`
echo "--------------------------------------------" >> $log/ChkDataEnabled-$DateTime.log
echo "START TIME: $DateTime" >> $log/ChkDataEnabled-$DateTime.log
counter=1
### while loop to read the source file from GLO.
while read rline
do
###check1 the current terminal used by subscribers.
mysql -udba -pwApNoMore -hdba-srv-01 -e "use tac; select subscriber.detection.msisdn, subscriber.detection.imsi, subscriber.detection.imei, if(subscriber.detection.last_configured is NULL, 'YES', 'NO') AS last_configured, tac.tac_terminal_mapper.make_name, tac.tac_terminal_mapper.terminal_name from tac.tac_terminal_mapper, subscriber.detection where subscriber.detection.msisdn='234$rline' and substring(subscriber.detection.imei,1,8) in (tac.tac_terminal_mapper.tac) order by subscriber.detection.last_detected desc limit 1 into outfile '$out/234$rline-subs-detection.csv' fields terminated by ',';"
###check2 if MSISDN detected by ADD or not and whether there no configuration sent to subs due to settings not released yet...
rowCount=`cat $out/234$rline-subs-detection.csv | wc -l`
if [ "$rowCount" -eq 0 ]; then
echo "No record found in detection table for MSISDN: 234$rline !" >> $log/ChkDataEnabled-$DateTime.log
rm $out/234$rline-subs-detection.csv
elif [ "$rowCount" -eq 1 ]; then
chkNULL=`cat $out/234$rline-subs-detection.csv | awk -F "," '{print $4}'`
getMSISDN=`cat $out/234$rline-subs-detection.csv | awk -F "," '{print $1}'`
getIMSI=`cat $out/234$rline-subs-detection.csv | awk -F "," '{print $2}'`
getIMEI=`cat $out/234$rline-subs-detection.csv | awk -F "," '{print $3}'`
getMAKE=`cat $out/234$rline-subs-detection.csv | awk -F "," '{print $5}'`
getTERMINAL=`cat $out/234$rline-subs-detection.csv | awk -F "," '{print $6}'`
if [ "$chkNULL" = "YES" ]; then
echo "Phone not configured due to settings not released yet for MSISDN: $getMSISDN, IMSI: $getIMSI, IMEI: $getIMEI, MAKE: $getMAKE, MODEL: $getTERMINAL !" >> $log/ChkDataEnabled-$DateTime.log
else
###check3 in otapmanager DB, om_history table to get the setting name that had sent before...
mysql -udba -pwApNoMore -hdba-srv-01 -e "use otapmanager; select vendor, model, settingname, updatedate, channel from om_history where da='$getMSISDN' and imei='$getIMEI' and settingname != 'sms' order by createdate desc limit 1 into outfile '$out/234$rline-subs-history.csv' fields terminated by ',';"
rowCount2=`cat $out/234$rline-subs-history.csv | wc -l`
if [ "$rowCount2" -eq 0 ]; then
echo "No record found in history table for MSISDN: 234$rline !" >> $log/ChkDataEnabled-$DateTime.log
elif [ "$rowCount2" -eq 1 ]; then
echo "Record greped from om_history table for MSISDN: 234$rline !" >> $log/ChkDataEnabled-$DateTime.log
getOM_history=`cat $out/234$rline-subs-history.csv`
echo "$getMSISDN, $getIMSI, $getIMEI, $getOM_history" >> $out/$DateTime-subs-data-enabled.csv
fi
rm $out/234$rline-subs-history.csv
fi
rm $out/234$rline-subs-detection.csv
fi
echo "Successfull check row number: $counter" >> $log/ChkDataEnabled-$DateTime.log
counter=`expr $counter + 1`
done < $in/gbamactiv.txt
#gzip $out/$Date-subs-data-enabled.csv
DateTime2=`date +%Y-%m-%d-%H-%M-%S`
echo "END TIME: $DateTime2" >> $log/ChkDataEnabled-$DateTime.log
echo "" >> $log/ChkDataEnabled-$DateTime.log
No comments:
Post a Comment