首页 > 数据库技术 > 详细

shell 脚本调用mysql存储过程

时间:2014-02-25 11:49:43      阅读:484      评论:0      收藏:0      [点我收藏+]
#!/bin/sh

##  The function of the script is used to balance statistics,we get
##  data from the table accseqs,after the analysis and calculation data,
##  the results will be inserted into the table acc_balances.

##  the script is executed at 1 o‘clock by every day.

DIR="/var/www/apps/sql"
DATE=$(date +%Y%m%d --date ‘1 days ago‘)
HOST=192.168.20.95
USER=admin
PASSWD=000000
DATABASE=zhxt
FILE=result.txt

cd ${DIR}

echo "the date:"${DATE}

SQL="exec mysql -h${HOST} -u${USER} -p${PASSWD} -D ${DATABASE} --default-character-set=utf8 -e \"call query_balance(${DATE})\""
echo ${SQL}>>${FILE}

if   mysql -h${HOST}            -u${USER}            -p${PASSWD}            -D ${DATABASE}            --default-character-set=utf8            -e "call query_balance(${DATE})"; then
    echo "ok">>${FILE}
else
    echo "fail">>${FILE}
fi

exit


shell 脚本调用mysql存储过程

原文:http://blog.csdn.net/duan19056/article/details/19822983

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!