修改oracle时区和uidb代码(匹配整数)

#!/bin/bash
make_decision()
{
su - oracle -c "sqlplus / as sysdba"<<EOF
 select dbtimezone from dual;
EOF
echo -n `date +%Y-%m-%d-%H:%M:%S` "Do you want to modify dbtimezone?(y/n)"
read ping

while [ 1 ]
do
if [ "$ping" = "y" ];then
 input_val
break
elif [ "$ping" = "n" ];then
 exit 0
else
 echo `date +%Y-%m-%d-%H:%M:%S` "Please input the right parameter."
 echo -n `date +%Y-%m-%d-%H:%M:%S` "Do you want to modify dbtimezone?(y/n)"
 read ping
fi
done
}
modify_dbtimezone()
{
#input_val
echo " "
echo -n `date +%Y-%m-%d-%H:%M:%S` "The parameter dbtimezone will be modified to $dbzone:00,are you sure?(y/n)"
read ping

while [ 1 ]
do
if [ "$ping" = "y" ];then
su - oracle -c "sqlplus / as sysdba"<<EOF
 alter database set time_zone='$dbzone:00';
 shutdown immediate
 startup
EOF
cutPath=`pwd`
touch $cutPath/tmp.log
chmod 777 $cutPath/tmp.log
echo "select dbtimezone from dual;">$cutPath/tmp.sql

su - oracle<<EOF
        sqlplus sqlplus $username/$icdpwd@$oracle_service<$cutPath/tmp.sql >$cutPath/tmp.log
EOF
val=`cat $cutPath/tmp.log -n | grep 14 | awk '{print $2}'`
su - oracle -c "sqlplus $username/$icdpwd@$oracle_service"<<EOF
 update t_dbtimezone set DBTZONE = '$val';
EOF
rm $cutPath/tmp.log>/dev/null
rm $cutPath/tmp.sql>/dev/null
break
elif [ "$ping" = "n" ];then
 input_val
 echo " "
 echo -n `date +%Y-%m-%d-%H:%M:%S`"The parameter dbtimezone will be modified to $dbzone,are you sure?(y/n)"
 read ping
else
 echo -n `date +%Y-%m-%d-%H:%M:%S` "Please input the right parameter:"
 echo -n `date +%Y-%m-%d-%H:%M:%S` "The parameter dbtimezone will be modified to $dbzone,are you sure?(y/n)"
 read ping
fi
done
}
input_val()
{
 while [ 1 ]
 do
  echo -n `date +%Y-%m-%d-%H:%M:%S` "Please input the dbtimezone of oracle:"
  read dbzone
  echo $dbzone |grep ^[0-9]*$>/dev/null
  var1=$?
  echo $dbzone |grep ^-[0-9]*$>/dev/null
  var2=$?
  if [ "$dbzone" = "" ];then
   echo "The parameter which you input is wrong!"
   else
   if [ "$var1" = 0 ] || [ "$var2" = 0 ];then
     if [[ $dbzone -le 12 ]] && [[ $dbzone -gt -13 ]];then
      echo " "
      break
      else
      echo "The parameter which you input is wrong!"
     fi
    else
    echo "The parameter which you input is wrong!"
   fi
  fi
 done
 while [ 1 ]
 do
  echo " "
  echo -n `date +%Y-%m-%d-%H:%M:%S` "Please input oracle service name :"
  read oracle_service
  if [ "$oracle_service" != "" ];then
   break
  else
   echo "Error input !"
  fi
 done
 
 while [ 1 ]
 do
  echo -n `date +%Y-%m-%d-%H:%M:%S` "Please Input Username of uidb:"
  read username
  if [ "$username" != "" ];then
   break
  else
   echo "Error input !"
  fi
 done
 
 while [ 1 ]
 do
  echo -n `date +%Y-%m-%d-%H:%M:%S` "Please Input Password of uidb:"
  read -s icdpwd
  if [ "$icdpwd" != "" ];then
   break
  else
   echo "Error input !"
  fi
 done
}
make_decision
modify_dbtimezone

echo 6 |grep '^[0]$\|^[-]\{0,1\}[1-9][0-9]*$' 这个是匹配整数的匹配表达式
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值