configFile=../../parm/output.config
runFolder=`cat ${configFile}|grep runFolder |awk -F= '{print $2}'`
outputFolder=`cat ${configFile}|grep outputFolder |awk -F= '{print $2}'`
outputFile=${outputFolder}/tolvdl_w_new_.txt
logName=$1
logName=${logName##*/}
logName=${logName%%.*}
logName="${logName}.log"
log=${runFolder}/output_FOLDER/${logName}
table=TABLENAME
fileSign=VDL
DB_SERV=`cat ${configFile}|grep DB_SERV |awk -F= '{print $2}'`
sql_source=`cat ${configFile}|grep sql_OSL |awk -F= '{print $2}'`
sql_result=`cat ${configFile}|grep sql_OIL |awk -F= '{print $2}'`
##replace the deffirent table and file name
sh tableReplace.sh $sql_source $sql_result ${fileSign} ${table}
#zip temp parameter
outputZip=${outputFolder}/zip/
zipPre=VDL_PRE
zipSuf=.zip
#zipAppend=(a b c d e f g h i j)
zipAppend=($(echo {a..z}))
tempNum=0
pageNum=`cat ${configFile}|grep pageNum |awk -F= '{print $2}'`
#read the email config
echo `date` "-------read the output.config file ------" >$log
failStr=`cat ${configFile}|grep fail |awk -F= '{print $2}'`
successStr=`cat ${configFile}|grep success |awk -F= '{print $2}'`
operatorName=`cat ${configFile}|grep operator |awk -F= '{print $2}'`
emailTitle=`cat ${configFile}|grep title |awk -F= '{print $2}'`
echo `date` "-------start to connect the DB and ouput the file ------" >>$log
#
#sqlplus to spool export the file
#
sqlplus -s /@${DB_SERV}<<EOF >>$log 2>&1
WHENEVER SQLERROR exit failure rollback
set echo off
set feedback off
set termout off
set trimspool off
set linesize 1078
set pagesize 0
set heading off
spool $outputFile
@${sql_result}
spool off
EOF
if [ $? -eq 0 ]; then
echo `date` ${successStr} >>$log
else
echo `date` ${failStr} $log>>$log
exit 1
fi
if [ -s $sql_result ]; then
rm $sql_result
fi
#make the file header and foot
lineLen=`cat ${configFile}|grep lineLen |awk -F= '{print $2}'`
dateStr=$(date +%m%d%y)
header=${dateStr}${fileSign}
while [ ${#header} -lt ${lineLen} ]
do
header=${header}0
done
lastLine=$(tail -1 ${outputFile})
rowNum=${lastLine:1:9}
#check the rownum is 0?----
if [ $rowNum = "000000000" ] ; then
tableEmpty=`cat ${configFile}|grep tableEmpty |awk -F= '{print $2}'`
echo `date` ${tableEmpty}---${table}>>$log
rm ${outputFile}
#java com.javamail
exit 1
fi
lastFileNum=`expr $rowNum % $pageNum `
#delete the last row
:|dd of=$outputFile seek=1 bs=$(($(find $outputFile -printf "%s")-$(tail -1 $outputFile|wc -c)))
#split the outputFile 2 million per file
echo `date` "-------start to split the file to ${pageNum} per file ------" >>$log
if [ -s $outputFile ]; then
mkdir ${outputZip} >>$log 2>&1
split -l ${pageNum} $outputFile ${outputZip}temp_ >>$log 2>&1
echo `date` "-------end to split the file to ${pageNum} per file ------" >>$log
#add the file header and footer
folderLen=$(ls -l ${outputZip}|grep "^-"|wc -l)
folderLen=`expr $folderLen - 1 `
for file_a in ${outputZip}/*; do
sed -i "1i${header}" $file_a
tempfoot=""
if [ $folderLen -eq $tempNum ] ; then
while [ ${#lastFileNum} -lt 9 ]
do
lastFileNum=0${lastFileNum}
done
tempfoot="V${lastFileNum}"
else
while [ ${#pageNum} -lt 9 ]
do
pageNum=0${pageNum}
done
tempfoot="V${pageNum}"
fi
while [ ${#tempfoot} -lt ${lineLen} ]
do
tempfoot=${tempfoot}0
done
echo $tempfoot >>$file_a
let tempNum++
done
tempNum=0
##END ADD HEADER AND FOOT
#gzip the file
for file_a in ${outputZip}/*; do
echo `date` "-------start to zip ------${outputFolder}/${zipPre}${zipAppend[$tempNum]}${zipSuf} from ${file_a} ">>$log
fileTarget=${outputZip}/${zipPre}${zipAppend[$tempNum]}.txt
mv ${file_a} ${fileTarget}
zip -qm ${outputFolder}/${zipPre}${zipAppend[$tempNum]}${zipSuf} ${fileTarget} >>$log 2>&1
echo `date` "-------End to zip ------${outputFolder}/${zipPre}${zipAppend[$tempNum]}${zipSuf} from ${fileTarget} ">>$log
let tempNum++
done
rm -rf ${outputZip}
rm -f $outputFile
echo `date` "-------remove the file-----${outputZip} and --${outputFile}">>$log
fi
分享到:
相关推荐
1 输入 adb shell evi record 后,做自己想要重复执行的操作。 2 输入 adb shell evi replay -t n ,即可重复执行操作,n代表想要重复执行的次数。 adb shell evi Usage: evi record [-f ] [] - record system ...
Which shell to use with AWK? Dynamic Variables The Essential Syntax of AWK Arithmetic Expressions Unary arithmetic operators The Autoincrement and Autodecrement Operators Assignment Operators ...
export CHANGEIP_RECORD=myrecord.example.com 然后拉取最新的镜像并运行一次性容器来执行脚本: docker pull tribou/changeip-updater docker run --rm -it \ -e 'CHANGEIP_USERNAME' \ -e 'CHANGEIP_PASSWORD...
ORACLE常用命令 一、ORACLE的启动和关闭 1、在单机环境下 要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下 su - oracle a、启动ORACLE系统 oracle>svrmgrl SVRMGR>connect internal ...
Python参考手册,官方正式版参考手册,chm版。以下摘取部分内容:Navigation index modules | next | Python » 3.6.5 Documentation » Python Documentation contents What’s New in Python ...
# To create a new change record, leave the brackets empty. After the upload is complete the changes will have an additional Patch Set. If you only want to upload the currently checked out Git branch...
<END> 48,ShellLnk.zip ShellLink ActiveX Control 1.0 can retrives and save all the information from a shortcut file(.lnk extension) which can be accessed by using various properties and methods...
cube.zip This example demonstrates how to rotate a cube in visual basic.<END><br>17 , sprite1.zip This is an Excellent example on how to use sprites in your program.<END><br>18 , charcreate.zip...
2.2.5 Exit from the Python Shell 27 2.3 BATCH MODE 27 2.3.1 Comments 29 2.3.2 Indentation 30 2.4 CHOOSING AN EDITOR 32 2.4.1 Sublime Text 32 2.4.2 Atom 33 2.4.3 PyCharm 34 2.4.4 Spyder IDE 35 2.4.5 ...
Try It Out: Very Simple Record Retrieval 436 Try It Out: Very Simple Record Storage 438 Try It Out: Data Storage in MySQL 439 Try It Out: Storing and Retrieving Documents 441 Try It Out: A ...
10)..Fixed: Ignore timeouts from Shell_NotifyIcon 11)..Fixed: Possible failure to handle/process stack overflow exceptions 12)..Changed: VCL/CLX/FMX now will assign Application.OnException handler ...
Record: 252; Size 344064. ---磁带机文件头大小 tcopy: File: 1; End of File after: 252 Records, 526729216 Bytes. ---文件大小 tcopy: The end of the tape is reached. tcopy: The total tape length is ...
Steps to record and edit powerful macros to quickly and efficiently edit files Using "copied" and "selected" variables for dynamic macros Use copied and selected text in macros to dramatically ...
2.3 Shell commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5 6 6 6 6 6 7 7 7 8 11 11 13 15 15 16 GDB Commands . . . . . . . . . . . . . . . . . . . . . . . . ...