Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1606812
  • 博文数量: 409
  • 博客积分: 6240
  • 博客等级: 准将
  • 技术积分: 4908
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-01 00:04
文章分类

全部博文(409)

文章存档

2021年(1)

2019年(1)

2017年(1)

2016年(13)

2015年(22)

2013年(4)

2012年(240)

2011年(127)

分类: LINUX

2013-08-22 21:22:27

源自百度的一个人发的问题,当时没什么事儿,就写了脚本,在这里分享or记录一下:

  1. [root@yang testshell]# cat tabletest.sh
  2. #!/bin/bash
  3. su - oracle <<ok
  4. fuckyou(){
  5. sqlplus /nolog <<fuck
  6. conn scott/yk123;
  7. select table_name from user_tables;
  8. exit;
  9. fuck
  10. }
  11. fuckyou >>/home/oracle/output.txt;
  12. exit
  13. ok
  14. #fuckyou >>/home/oralce/output.txt;如果在这里,那么则无法找到fuckyou这个函数。
  15. read -p "please input tablename: " -t 5 tablename
  16. tn=$(echo ${tablename} |tr [a-z] [A-Z])
  17. grep -l "${tn}" /home/oracle/output.txt && echo "the table ${tablename} exist.";
  18. [root@yang testshell]#sh tabletest.sh
  19. please input tablename: emp
  20. /home/oracle/output.txt
  21. the table emp exist.
  22. [root@yang testshell]#






阅读(4949) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~