您的位置:首页 > 运维架构 > Shell

编写shell脚本unload表格里的内容到指定文件里

2016-03-16 11:59 453 查看
$HOME/.profile

//这里是不赋值环境变量,直接引用.profile文件。

Today=`date +%Y%m%d`

//这里是给当天日期变量赋值

gjfile=khtgjmx.$Today.210000.0000.dat

khfile=khtqykh.$Today.210000.0000.dat



dbaccess gafeywk<<!

//选定数据库

unload to $gjfile select b.xybh,a.ywrq,a.cgje from yltyw_plmxb a ,yltyw_gjxyb b where a.zt='0' and a.shzt='0' and a.ywrq='$Today' and a.zcyhdm=b.gjyhdm  and a.zczh=b.gjyhzh and a.zrzh=b.qyzh ;

//数据库操作语句,意思是把表格里的内容下载到gjfile文件里。

unload to $khfile select zjhm,bljg,xybh,qyzh,zhhm,blrq,gjzqlx,zjlx from yltyw_gjxyb where zt='0';



!

//关闭数据库

gzip -f $gjfile;

gzip -f $khfile;

//压缩文件



echo "正在发送备份文件..."

echo "user gafe gafe"           >ftp.tmp

echo "bin"                      >>ftp.tmp

echo "cd /gafe/ftpdata"         >>ftp.tmp

echo "put $gjwjm.gz"            >>ftp.tmp

echo "put $khwjm.gz"            >>ftp.tmp

echo "bye"                      >>ftp.tmp

ftp -i -n 168.31.63.233         <ftp.tmp

echo "Finished!"

//使用ftpdata把文件发送到java同事要取文件的服务器上。

[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: