当前位置: 代码迷 >> 计算机图书 >> 转移东西所用解决思路
  详细解决方案

转移东西所用解决思路

热度:772   发布时间:2013-02-26 00:00:00.0
转移东西所用
没啥内容 爪黄你可以贴出来了

------解决方案--------------------------------------------------------
. $HOME/.bash_profile
 
#存放日志的文件目录
dir_path=$HOME/tmp/hrh/test
#生成的报表文件
dest_file=$HOME/tmp/hrh/test/11.rpt
export dest_file
err_flag="Exit with code "
export err_flag
batch_flag="batch_name = \""
export batch_flag
export cpycode
begindate=`date -u '+%Y%m%d %H:%M:%S'`
echo "----------------$begindate---------------------"
 
cd $dir_path
rm -rf $dest_file
echo "公司名|模块名|出错代码" >> $dest_file
for file in `ls batch???.log 2>/dev/null` 
do
dos2unix $file
cpycode=`expr substr $file 6 3`
awk '{
dest_file1 = ENVIRON["dest_file"]
err_flag1 = ENVIRON["err_flag"]
batch_flag1 = ENVIRON["batch_flag"]
batch_start_flag1 = ENVIRON["batch_start_flag"]
batch_end_flag1 = ENVIRON["batch_end_flag"]
cpycode1 = ENVIRON["cpycode"]
len = length($0)
if ( (start_pos = index($0,err_flag1)) != 0 )
{
start_pos = start_pos + length(err_flag1);
err_code = substr($0,start_pos,len);
/*printf "err_code:[%d]\n",str;*/
flag=1;
}
if ( (start_pos = index($0,batch_flag1)) != 0 )
{
tmp = substr($0,start_pos,len);
if ( split(tmp,num,"\"") > 0 )
{
batch_name = num[2];
}
/*printf "batch_name:[%s]\n",batch_name;*/
}
if ( flag == 1 && match($0,/^-*-$/) != 0)
{
flag=0;
printf "%s|%s|%s\n",cpycode1,batch_name,err_code;
}
}' $file >> $dest_file
done
enddate=`date -u '+%Y%m%d %H:%M:%S'`
echo "----------------$enddate---------------------"
  相关解决方案