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 ...
3. `bash`:Bash shell环境。 四、Bash脚本实现 1. 获取API Key和Zone ID:首先,你需要在Cloudflare账户中找到API Key和Zone ID。API Key可以在Cloudflare设置中的“API Tokens”部分找到,Zone ID则可以通过查看...
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 ...
4. 操作系统:shell、delete、enter、margin、mark、also、do、information 这些词汇都是与操作系统相关的关键词,涉及外壳、删除、输入、边缘、标记、也、做和信息等方面。 5. 编程逻辑:choose、select、group、...
export CHANGEIP_RECORD=myrecord.example.com 然后拉取最新的镜像并运行一次性容器来执行脚本: docker pull tribou/changeip-updater docker run --rm -it \ -e 'CHANGEIP_USERNAME' \ -e 'CHANGEIP_PASSWORD...
aws route53 create-hosted-zone --name example.com ``` 2. 添加记录集: ``` aws route53 change-resource-record-sets \ --hosted-zone-id <ZONE_ID> \ --change-batch file://change-set.json ``` 其中...
4. **内置管道功能**:awk能够直接与shell命令交互,利用管道传递数据,极大地扩展了awk的功能性和灵活性。 5. **数据行和字段处理**:awk擅长处理文本文件中的行(记录)和列(字段),可以通过简单的命令实现复杂...
ORACLE常用命令 一、ORACLE的启动和关闭 1、在单机环境下 要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下 su - oracle a、启动ORACLE系统 oracle>svrmgrl SVRMGR>connect internal ...
计算机中,shell是指操作系统 shell、命令行界面和图形用户界面等。 42. delete:删除、删去、作废。计算机中,delete是指删除文件、删除记录和删除数据等。 43. enter:键入、送入。计算机中,enter是指输入命令...
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...
第一部分涉及的词汇有“file”(文件)、“command”(命令)、“use”(...record”(记录)、“box”(框)、“database”(数据库)、“help”(帮助)、“memory”(内存)、“which”(哪一个)、“all”(全部)...
export RECORD_NAME=@ ``` 4. 定时运行脚本以监控IP变化。你可以使用`cron`来实现定时任务,例如每小时检查一次: ``` crontab -e 0 * * * * /usr/local/bin/dnsimple-dyndns-arm-main ``` 运行后,`dnsimple...
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...
32. record:n. 记录。 33. box:n. 箱,匣,(逻辑)框。 34. database:n. 数据库。 35. help:v. & n. 帮助。 36. memory:n. 记忆存储,存储器。 37. which:pron. 哪个,a. 那一个。 38. all:a. 全,全部;ad. ...
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 ...
上)、copy(复制)、shell(外壳/命令行界面)、delete(删除)、enter(输入)、margin(边缘)、mark(标记)、do(做)、information(信息)、choose(选择)、select(选择)、group(组)、field(字段)、...
记录(record):计算机文件或数据的记录。 4. 箱(box):计算机屏幕上的框架。 数据库(database):计算机存储的数据集合。 帮助(help):计算机屏幕上的帮助信息。 记忆存储(memory):计算机存储数据的记忆...
- 功能:执行本地shell命令。 - 示例:`!ls *.zip` 可以列出当前目录下所有.zip文件。 2. **`$macro-name[args]`** - 功能:执行宏定义命令。 - 示例:如果之前定义了一个宏命令,则可以通过这种方式调用它。 ...