linux shell 中如何使用dblink 查询数据返回变量并ftp上传

最近遇到个小需求,在内网区测试数据库机器 129上用linux shell 脚本查询 出正式库 141 的数据,得到变量的值后将它输入到文件file中,并将文件ftp 长传到外网区的 35,这块我不是很熟,话不多说,直接上脚本了

#!/bin/bash
#. /etc/profile
. ~/.bash_profile
set serveroutput on
set timing on
dblink="hlwsb_sjfx/hlwsb_sjfx@wssbdb_new"




weblogic_thread_count="select count(1) from hlwsb_sjfx.dzswj_monitor_weblogic_thread t where t.mon_date>sysdate - (30/1440) and t.hoggingthreadcount>30"
weblogic_thread_mx="select to_char(wmsys.wm_concat(t.serverport)) from hlwsb_sjfx.dzswj_monitor_weblogic_thread t where t.mon_date>sysdate - (30/1440) and t.hoggingthreadcount>30 group by t.serverport"

VALUE_COUNT=/orahome/app/oracle/product/11.2.0/oracle/bin/sqlplus -silent ${dblink}&lt;&lt;EOF<br/>set pagesize 0 feedback off verify off heading off echo off<br/>${weblogic_thread_count}<br/>/<br/>exit;<br/>EOF

VALUE_MX=/orahome/app/oracle/product/11.2.0/oracle/bin/sqlplus -silent ${dblink}&lt;&lt;EOF<br/>set pagesize 0 feedback off verify off heading off echo off<br/>${weblogic_thread_mx}<br/>/<br/>exit;<br/>EOF

echo "VALUE_COUNT:"$VALUE_COUNT > ./zabbix.file
echo "VALUE_MX:"$VALUE_MX >> ./zabbix.file

############################################################ FTP 上传至 外网35 #####################################################

ctldir=/home/oracle/logstail/weblogic/ctl

USER=weblogic
#密码
PASSWORD=Hlwsb101#%
#下载文件目录1
SRCDIR=/home/weblogic/zabbix/zabbix_check_weblogic_thread
#FTP目录(待下载文件目录)
DESDIR=/home/oracle/zabbix/zabbix_check_weblogic_thread
#银联IP
IP=87.16.16.218
#端口
PORT=3522









lftp -u ${USER},${PASSWORD} sftp://${IP}:${PORT}<<EOF

lcd ${DESDIR}
cd ${SRCDIR}
mput *.file
by
EOF



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章