#!/bin/bash
function usage
{
if [ $# -gt 0 ]; then
echo $@ >&2
fi
cat << EOF >&2
usage : t [-v][-h host_name][-P port_num][-u user_name][-p password][-D db_name]
Other parameters (-h, -P, ... -D) = Same as mysql command (refer to mysql documentation).
EOF
exit 1
}
function cat_args
{
echo $msql $1 $2
}
msql='/usr/local/mysql5/bin/mysql '
called_with="$@"
while getopts "vh:P:u:p:D:" arg
do
case $arg in
h|P|u|p|D)
msql=$(cat_args -$arg$OPTARG)
;;
v)
verbose=1
;;
*|?)
usage incorrect parameter
;;
esac
done
echo $msql
echo show tables|$msql