Shell脚本抽实例.docVIP

  • 12
  • 0
  • 约18万字
  • 约 30页
  • 2016-12-03 发布于河南
  • 举报
Shell脚本抽实例

Shell脚本抽取实例 #!/usr/bin/ksh 1. 应用地址变量引用 myself=backup_chncm_file.sh logfile=${MCB_HOME}/${MCB_APPID}/var/log/${procname}.log 2. case实例 case ${MCB_APPID} in chs) ic_dir=/opt/mcb/chs/data/*/inroam/incoming arch_dir=/opt/mcb/chs/back file_pattern=[AC][CD]?????CHNCM* db_user=chsdba ;; ops) ic_dir=/opt/mcb/ops/data/incoming/ics arch_dir=/opt/mcb/ops/arch/incoming/ics file_pattern=[AC][CD]?????CHNCM* db_user=iogsmdba ;; *) MCB_APPID=dps1 echo MCB_APPID is not in chs/ops, please check! exit 1 ;; esac 3. 判断参数个数实例 if [ $# -lt 1 ];then echo SERIOUS:DBMSG() need 1 argument: DEBUGMSG return 1 fi 4. 判断结果实例 if [ $? -ne 0 ];then message=query carriers table failed! db_user=${db_user} db_passwd=${db_passwd} db_sid=int1 write_log SERIOUS exit 1 fi 5. 判断目录实例 if [ ! -d ${carrier_arch_dir} ];then mkdir -p ${carrier_arch_dir} fi if [ -d $DirPath -a -r $DirPath -a -w $DirPath ] then return 0 else echo Directory:$DirPath not exists or is not writeable exit 1 fi 5. 判断文件实例 if [ -z $bassFile ];then echo SERIOUS:unitcode in config file is null! exit exit 1 fi 6. getdbpwd实例 db_passwd=$(getdbpwd ${db_user}) if [ $? -ne 0 -o -z ${db_passwd} ];then message=getdbpwd ${db_user} failed! write_log SERIOUS return 1 fi 7. and实例 if [ not_open_flag -eq 1 -a have_arch_before -eq 1 ];then fi 8. or实例 if [ not_open_flag -eq 1 -o have_arch_before -eq 1 ];then fi 9. find实例 ##查找文件匹配 find . -type f -name $file_pattern ##查找目录匹配并且消除notice/match目录查找 find . -type d /notice/match/ -prune ##查找目录下面比$tagfile晚的文件 find ${ic_dir} -type f -name $file_pattern ! -newer $tagfile find $dir -mtime +$days -type f -exec rm -f {} \; find $dir -mtime -$days -type f -exec ls -l {} \; 10. basename文件名实例 FullPath=/opt/mcb/ibip/sourcefile.gz FileName=`basename $FullPath` 10. 配置文件实例 configfile=$MCB_HOME/${MCB_APPID}/conf/${modulename}.conf . ./cfConfigFile.sh cfInit ${configfile} noLock readOnly ftpip=$(cfGetConfigItem common ftphost) ftpuser=$(cfGetConfigItem

文档评论(0)

1亿VIP精品文档

相关文档