- 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
您可能关注的文档
最近下载
- 汽车热管理系统仿真分析与实例解析 课件 06 AI 技术与汽车热管理.pptx
- 《钛合金锻坯 缺陷检测 相控阵超声水浸检测方法》.pdf VIP
- F665065【复试】2024年长春理工大学070200物理学《复试物理光学》考研复试终极预测5套卷.pdf VIP
- 7.2《秦腔》课件(共43张PPT)(含音频+视频).pptx VIP
- 《急危重症护理学》配套ppt 9.第九章 泌尿系统功能监护.ppt VIP
- ZR-ZT-无油空压机培训资料.ppt VIP
- 2025年度医院党支部组织生活会临床医生个人对照检查材料.doc VIP
- (国家标准)GB T 7424.1-2003 光缆总规范 第1部分:总则.pdf
- 《工业控制系统信息安全防护指南》解读.doc VIP
- 救护员培训应急救护PPT课件.pptx VIP
原创力文档

文档评论(0)