-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcms_abusive.sh
59 lines (44 loc) · 1.61 KB
/
cms_abusive.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#Author: Maynard Louis E. Prepotente
#Date: November 15,2019
set -vx
pDate=`date +%Y%m`
lDate=`date '+%d/%m/%y %H:%M'`
fileDIR=/apps/splunk/etc/apps/csg/bin/scripts/uploads
logDIR=/apps/splunk/etc/apps/csg/bin/scripts/log
abusiveDIR=/home/cms_user/scripts/BLOCKING_OF_ABUSIVE_ACCOUNTS
file=$1
filedate=$(echo "$file" | cut -f 1 -d '.')
if [ ! -f $fileDIR/$file ]
then
echo "${lDate} File not found."
exit 1
fi
echo "${lDate} Processing ${file}..."
filename="insert_fraud_msisdn_${filedate}"
echo ${filename}
cnt=0
filenum=1
#script in creating insert script
echo "${lDate} creating insert script... " | tee -a ${logFILE}
DONE=false
until $DONE; do
read x || DONE=true
((cnt=cnt+1))
min=`echo ${x} | cut -c 4-`
echo "insert into gtt_reports values ('${min}');" >> ${fileDIR}/${filename}_${filenum}.sql
if [ $cnt -eq 50000 ]; then
filenum=`expr "$filenum" + 1`
cnt=0
fi
done < ${fileDIR}/${file}
#Create SQL Script
echo "@${filename}_${filenum}.sql" >> ${fileDIR}/UNICARD_APPS_SPLUNK.sql
echo "@batch_acct_cancellation_blocking_of_abusive_accounts.sql" >> ${fileDIR}/UNICARD_APPS_SPLUNK.sql
echo "@Blocked_accounts_script.sql" >> ${fileDIR}/UNICARD_APPS_SPLUNK.sql
echo "exit;" >> ${fileDIR}/UNICARD_APPS_SPLUNK.sql
#Dump files to CMS
scp ${fileDIR}/${filename}_${filenum}.sql [email protected]:$abusiveDIR
scp ${fileDIR}/UNICARD_APPS_SPLUNK.sql [email protected]:$abusiveDIR
#Execute CMS script
ssh [email protected] /bin/bash -x /home/cms_user/scripts/.BLOCKING_OF_ABUSIVE_ACCOUNTS_SPLUNK.sh