#!/bin/bash
#author xiaoweige
#todo: ip -- > ingredient or ingredient -- > ip

#todo: get the ip of the given ingredient
function ingredient_ip() {
#todo: get the ip of the ingredient given
  mysql -uroot -pengine -e "select * from ipandingredient.ipandingredient where env ='$1' and ingredient='$2'"
}
#todo: not sure what the ingredient is
function search_ingredient() {
  mysql -uroot -pengine -e "use ipandingredient ;select * from ipandingredient where ingredient like '%${1}%' "

}
#todo: get the ip of the ingredient given
function ip_ingredient() {
  mysql -uroot -pengine -e "use ipandingredient; select * from ipandingredient where env='$1' and ip='$2' "

}

function usage() {
  echo "to get ingredient USAGE: ./$0 ip"
  echo "to get ip USAGE: ./$0 ingredient"
  echo "search ingredient ./$0 sth"

}

function main(){
  if [ $# -eq 0 ]
  then
    usage
  elif [ $# -eq 1 ]
  then
    search_ingredient $1
  elif [ $# -eq 2 ]
  then
  argtype=`echo $2|egrep [1-9+\.]`
  if [ -z $argtype ]
  then
    ingredient_ip $1 $2
  else
    ip_ingredient_ip $1 $2
  fi
fi

}
main $*

最新文章

  1. 【CentOS】虚拟机网络配置与远程登录
  2. 【javascript 面试笔试】1、几道笔试题
  3. JAVA排序--[冒泡排序]
  4. redis在.NET下的使用
  5. 与时间有关的windows函数
  6. 关于Spring的BeanPostProcessor
  7. 记一次亲身踩过的hibernate的bug
  8. MySql 修改外键 支持级联删除
  9. CodeChef Little Elephant and Mouses [DP]
  10. 基于scrapy爬虫的天气数据采集(python)
  11. Oracle 数据库基础知识
  12. java.util.Stack类中的peek()方法
  13. 解决 ora-28001 密码过期的处理办法
  14. jsp 一点点
  15. git 用法---成功添加一个文件到github
  16. wps word改多级编号为2.1
  17. ELK新手教程(二)
  18. mySQL 约束 (Constraints):一、非空约束 NOT NULL 约束
  19. Using Dtrace OEL 6.X
  20. MySQL 两个数据库表中合并数据

热门文章

  1. HTML存储详解
  2. CentOS7系列--1.4CentOS7服务
  3. Python这个缩进让我焦头烂额!最奇葩的缩进...
  4. node-sass 解决 no such file or directory
  5. Oracle案例11——Oracle表空间数据库文件收缩
  6. 委托学习总结(二)匿名方法和lambda表达式
  7. Docker 报错 error during connect: Get pipe/docker_engine: The system cannot find the file specified. - 摘要: 本文讲的是Docker 报错 error during connect: Get pipe/dock
  8. GBK与UTF-8编码错误转换后,无法再正确恢复
  9. 转:线程Thread (1)
  10. 解析苹果的官方例子LazyTableImages实现图片懒加载原理