源自百度的一个人发的问题,当时没什么事儿,就写了脚本,在这里分享or记录一下:
-
[root@yang testshell]# cat tabletest.sh
-
#!/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;如果在这里,那么则无法找到fuckyou这个函数。
-
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]#
阅读(5004) | 评论(0) | 转发(0) |