工作临时写的,生成和调用shell

#!/bin/bash

##################################################################

#主要是动态生成一个新的执行脚本

#再调用这个脚本与数据库中的内容对比

#检查是否有差异

#20090916

###################### 数据库 相关信息 ######################                         
DATA_SERVER_NAME=XXXX                                                               
DATA_USER=XXXX
DATA_PASS=XXXX
###################### 数据库 相关信息 ######################
function lrysqlexec()                                                                  
{                                                                                     
  echo "$ORACLE_HOME/bin/sqlplus -s ${DATA_USER}/${DATA_PASS}@${DATA_SERVER_NAME} <<EOF
  set feedback off;                                                                   
  set pagesize 0;                                                                     
  set tab on;                                                                         
  set line 1000;                                                                      
  set echo off;                                                                       
  set trims on;                                                                       
  $1;                                                                                 
  quit;                                                                               
  EOF"                                                                                
}

 

echo "请输入账务月(eg:20090911)"
read date
cd /settle3/test/ftp
if [ -f ACR_RECORD_${date}.new.gz ]
then
gunzip ACR_RECORD_${date}.new.gz
fi
> exefinddiff.sh
echo "#!/bin/bash" >> exefinddiff.sh
echo "echo /"查找ACR_RECORD_${date}.new文件/"" >> exefinddiff.sh
echo "输入serverkey:"
read serverkey
echo "输入chargemode:"
read chargemode
echo "count1=/`grep '( 0 , $serverkey , $chargemode' ACR_RECORD_${date}.new | wc -l/`" >> exefinddiff.sh
echo 'echo "count1等于$count1"' >> exefinddiff.sh
echo "cd /settle3/test" >> exefinddiff.sh
echo "count2=/`grep '( 0 , $serverkey , $chargemode' ACR_RECORD_${date}.old | wc -l/`" >> exefinddiff.sh
echo 'echo "count2等于$count2"' >> exefinddiff.sh
tmp=`echo "$date" | awk '{print substr($1,7,2)'}`
echo $tmp
echo "count3=/`grep '( 0 , $serverkey , $chargemode' ${tmp}app.sql | wc -l/`" >> exefinddiff.sh
echo 'echo "count3等于$count3"' >> exefinddiff.sh
echo 'total=`expr $count1 + $count2 + $count3`' >> exefinddiff.sh
echo 'echo "原始数据总共有:$total"' >> exefinddiff.sh
echo 'echo 查看数据库中的数据'
lrysqlcount="SELECT y.count FROM ywl_check_count y WHERE y.service_key=$serverkey AND y.charge_mode=$chargemode and y.data_date=$date";
lrycount=`lrysqlexec "$lrysqlcount" | sh | awk '{print $1}'`
echo "数据库中的信息为:$lrycount"
echo "dbcount=$lrycount" >> exefinddiff.sh
echo 'diff=`expr ${total} - ${dbcount}`' >> exefinddiff.sh
echo "echo -e /"数据库的数据/t原始数据/t差异/"" >> exefinddiff.sh
echo 'echo -e "${dbcount}/t/t$total/t/t$diff"' >> exefinddiff.sh
echo "echo /"end subfunction/"" >> exefinddiff.sh
pwd
chmod +x exefinddiff.sh
exefinddiff.sh
echo "end ALL"

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值