Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1374545
  • 博文数量: 112
  • 博客积分: 7112
  • 博客等级: 少将
  • 技术积分: 1299
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-31 16:27
文章分类

全部博文(112)

文章存档

2011年(19)

2010年(20)

2009年(16)

2008年(20)

2007年(37)

分类: LINUX

2007-12-23 21:56:34

   用法: sh start.sh {filter|filter_city|filter_prov|city|prov}

   例如: sh start.sh  filter        只过滤黑名单
        sh start.sh  filter_city   先过滤黑名单并分地市    
     sh start.sh  filter_prov   先过滤黑名单并分省
     sh start.sh  city          只做分地市
     sh start.sh  prov          只做分省
用到的脚本有filter.sh filter mdn_city.sh mdn_prov.sh start.sh
[oracle@lmailmms filter]$ more start.sh
#!/bin/bash
DATE=`date +%Y_%m_%d_%H_%M_%S`
case "$1" in
  filter)
       echo "starting filter mdn ..." >> log/log.txt
       echo "=======开始过虑黑名单操作`date +%Y-%m-%d_%H:%M:%S`====="
       echo "=======开始过虑黑名单操作`date +%Y-%m-%d_%H:%M:%S`=====">>log/log.txt
       sh filter.sh
       cp users.txt log/users_filter_$DATE.txt
       echo "=======过滤黑名单结束`date +%Y-%m-%d_%H:%M:%S`,new.txt为所要的结果。=====
===">>log/log.txt
       echo "=======过滤黑名单结束`date +%Y-%m-%d_%H:%M:%S`,new.txt为所要的结果。=====
==="
  ;;
  filter_city)
       echo "starting filter_city mdn ..." >>log/log.txt
       echo "=======开始过虑黑名单并分地市操作`date +%Y-%m-%d_%H:%M:%S`=====
=">>log/log.txt
       echo "=======开始过虑黑名单并分地市操作`date +%Y-%m-%d_%H:%M:%S`.====
==="
       sh filter.sh
       cp users.txt log/users_filter_city_$DATE.txt
       mv  new.txt users.txt
       sh mdn_city.sh
       cp log/users_filter_city_$DATE.txt  users.txt
       echo "===过虑黑名单分地市结束`date +%Y-%m-%d_%H:%M:%S`,new.txt为所要的结果.
======="
       echo "===过虑黑名单分地市结束`date +%Y-%m-%d_%H:%M:%S`,new.txt为所要的结果.
=======">>log/log.txt
  ;;
  filter_prov)
       echo "starting filter_prov mdn ..." >>log/log.txt
       echo "=======开始过虑黑名单并分省操作`date +%Y-%m-%d_%H:%M:%S`============"
       echo "=======开始过虑黑名单并分省操作`date +%Y-%m-%d_%H:%M:%S`============">>lo
g/log.txt
       sh filter.sh
       cp users.txt log/users_filter_prov_$DATE.txt
       mv new.txt users.txt
       sh mdn_prov.sh
       cp log/users_filter_prov_$DATE.txt users.txt
       echo "=======过虑黑名单分省结束`date +%Y-%m-%d_%H:%M:%S`,new.txt为所要的结果.==
====="
       echo "=======过虑黑名单分省结束`date +%Y-%m-%d_%H:%M:%S`,new.txt为所要的结果.==
=====">>log/log.txt
  ;;
  city)
       echo "starting city mdn ..." >>log/log.txt
       echo "starting city mdn ..."
       echo "========开始分地市操作`date +%Y-%m-%d_%H:%M:%S`==============="
       echo "=====开始分地市操作`date +%Y-%m-%d_%H:%M:%S`==================">>
log/log.txt
       sh mdn_city.sh
       cp users.txt log/users_city_$DATE.txt
  ;;
  prov)
       echo "starting prov mdn ..." >>log/log.txt
       echo "starting prov mdn ..."
       echo "======开始分省操作`date +%Y-%m-%d_%H:%M:%S`==========================="
       echo "======开始分省操作`date +%Y-%m-%d_%H:%M:%S`===========================">
>log/log.txt
       sh mdn_prov.sh
       cp users.txt log/users_prov_$DATE.txt
  ;;
  *)
  echo "用法: ./start.sh {filter|filter_city|filter_prov|city|prov}"

  exit 1

esac
  exit 0

[oracle@lmailmms filter]$ more filter
sqlplus wlblsusr/XXXXXX <set feedback off
set heading off
set pagesize 0
spool new.txt
select * from temp t where not exists (select 1 from wl_bls_blacklist m where m.vc2mdn = t.mdn);
spool off
truncate table temp;
EOF
exit

[oracle@lmailmms filter]$ more filter.sh
#/bin/bash
#DATE=`date +%Y-%m-%d" "%H:%M:%S`
echo "开始过滤黑名单操作`date +%Y-%m-%d" "%H:%M:%S`"
echo "开始过滤黑名单操作`date +%Y-%m-%d" "%H:%M:%S`" >> log/log.txt
#把数据库临时表temp清空。
sqlplus wlblsusr/XXXXXX <truncate table temp;
EOF

if [ -s users.txt ]
   then
#       sh truncate_temp.sh
       dos2unix users.txt > /dev/null 2>&1
       sed 's/^86//;s/ *$//' users.txt > users1.txt
       sort -n -u users1.txt > users_temp.txt
       sqlldr wlblsusr/wlblsusr control=temp.ctl
       rm -f  new.txt
       sh filter
       awk '$1 >= 13000000000 && $1 <= 16000000000 ' new.txt > new
       sed 's/ *$//' new >new.txt
       MDN1=`cat users.txt |wc -l`
       MDN2=`cat new.txt   |wc -l`
       MDN3=`expr $MDN1 - $MDN2 `
       echo "过黑前为:$MDN1个号,过完后为:$MDN2个号,过滤掉:$MDN3个号。"
       echo "过黑前为:$MDN1个号,过完后为:$MDN2个号,过滤掉:$MDN3个号。" >>log/log.txt
       echo "黑名单过滤完成`date +%Y-%m-%d" "%H:%M:%S`."  >>log/log.txt
       echo "黑名单过滤完成`date +%Y-%m-%d" "%H:%M:%S`."
 
   else
       echo "users.txt文件不存在,或users.txt里没有内容。请核对。"
       echo "users.txt文件不存在,或users.txt里没有内容。请核对。" >> log/log.txt
fi
rm -f users1.txt users users_temp.txt new
#mv    users.txt log/users_filer_`date +%Y_%m_%d_%H_%M_%S`.txt

[oracle@lmailmms filter]$ more mdn_city.sh
#!/bin/bash
#DATE=`date +%Y-%m-%d" "%H:%M:%S`
echo "开始分地市操作`date +%Y-%m-%d" "%H:%M:%S`"
echo "开始分地市操作`date +%Y-%m-%d" "%H:%M:%S`" >> log/log.txt
if [ -s users.txt ]
   then
    dos2unix users.txt > /dev/null 2>&1
    sed 's/^86//;s/ *$//' users.txt > users1.txt
    sort -n -u users1.txt > users
    awk  'NR==FNR{a[$1]=$4}NR>FNR&&a[b=substr($1,1,7)]{print $1,a[b]}' cwm_mdn_prov users >new
    sort  -k 2 new > new.txt
    awk '{print $2}' new.txt |uniq -c > new_goup.txt
    cat new_goup.txt
    cat users.txt |wc -l >number
    echo "分地市操作完成`date +%Y-%m-%d" "%H:%M:%S`,共操作`cat number`个号码." >> log/log.txt
    echo "分地市操作完成`date +%Y-%m-%d" "%H:%M:%S`,共操作`cat number`个号码."
    echo "============================分地市结束`date +%Y-%m-%d_%H:%M:%S`,new.txt为所要的结果.======="
    echo "============================分地市结束`date +%Y-%m-%d_%H:%M:%S`,new.txt为所要的结果.=======">>log/log.txt
   else 
    echo "users.txt文件不存在,或users.txt里没有内容。请核对。"
    echo "users.txt文件不存在,或users.txt里没有内容。请核对。" >> log/log.txt
fi
rm -f new users number users1.txt

[oracle@lmailmms filter]$ more mdn_prov.sh
#!/bin/bash
#`date +%Y-%m-%d" "%H:%M:%S`DATE=`date +%Y-%m-%d" "%H:%M:%S`
echo "开始分省操作`date +%Y-%m-%d" "%H:%M:%S` "
echo "开始分省操作`date +%Y-%m-%d" "%H:%M:%S`" >> log/log.txt
if [ -s users.txt ]
   then
    dos2unix users.txt > /dev/null 2>&1
    sed 's/^86//;s/ *$//' users.txt > users1.txt
    sort -n -u users1.txt > users_temp
    awk  'NR==FNR{a[$1]=$5}NR>FNR&&a[b=substr($1,1,7)]{print $1,a[b]}' cwm_mdn_prov users_temp >new.txt
    sort  -k 2 new.txt > new_temp
    awk '{print $2}' new_temp |uniq -c > new_goup.txt
    cat new_goup.txt
    cat users.txt |wc -l >number
    echo "分省操作完成`date +%Y-%m-%d" "%H:%M:%S`共操作`cat number`个号码." >> log/log.txt
    echo "分省操作完成`date +%Y-%m-%d" "%H:%M:%S`共操作`cat number`个号码."
   else 
    echo "users.txt文件不存在,或users.txt里没有内容。请核对。"
    echo "users.txt文件不存在,或users.txt里没有内容。请核对。" >>log/log.txt
    echo "============================分省结束`date +%Y-%m-%d_%H:%M:%S`,new.txt为所要的结果.========="
    echo "============================分省结束`date +%Y-%m-%d_%H:%M:%S`,new.txt为所要的结果.=========">>log/log.txt
fi
rm -f new_temp users_temp number users1.txt
阅读(2235) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~