#!/bin/bash
su - oracle <<ok
fuckyou(){
sqlplus /nolog <<fuck
conn scott/yk123
select table_name from user_tables
exit
fuck
}
fuckyou >>/home/oracle/output.txt
exit
ok
#fuckyou >>/home/oralce/output.txt
read -p "please input tablename: " -t 5 tablename
tn=$(echo ${tablename} |tr [a-z] [A-Z])
grep -l "${tn}" /home/oracle/output.txt && echo "the table ${tablename} exist."
[root@yang testshell]#sh tabletest.sh
please input tablename: emp
/home/oracle/output.txt
the table emp exist.
[root@yang testshell]#
请仔细阅读。
注意此处:isql -U natuser -P zjtt@nat -S natdb <<END
如下供参考
isql -U natuser -P zjtt@nat -S natdb <<END >out.txt
即将查询结果重定向到out.txt文件中
·2若要输出至变量
isql -U natuser -P zjtt@nat -S natdb <<END |read xarg
·3若要循环输出至变量,可参照read方式类推
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)