Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #---------------------
- # umask 0077
- # echo -e "[client]\npassword = password" > my.cnf
- # echo "select 1 as one" | mysql --defaults-extra-file=my.cnf -u oreore
- function Encho()
- {
- echo "[`date '+%Y/%m/%d %T'`] $1"
- }
- MYSQL_USER='root'
- MYSQL_PW=''
- MYSQL_URL='localhost'
- MYSQL_DB='test_db'
- # MYSQL_LOGIN="-h ${MYSQL_URL} -u${MYSQL_USER} -p${MYSQL_PW} --database=${MYSQL_DB}"
- MYSQL_LOGIN="-h ${MYSQL_URL} -u${MYSQL_USER} --database=${MYSQL_DB}"
- MYSQL_IGNORE_WARNING='Warning: Using a password on the command line interface can be insecure.'
- function run_select_sql()
- {
- unset ret
- unset SQLGetValue
- SQLGetValue=$1
- RetValue=`echo "${SQLGetValue}" | mysql ${MYSQL_LOGIN} --skip-column-names 2>&1`
- Ret=$?
- RetValue=${RetValue#$MYSQL_IGNORE_WARNING}
- if [ $Ret -ne 0 ]; then
- Encho "on error($Ret) $SQLGetValue"
- echo $RetValue
- return $Ret
- fi
- # ValueArray=(${RetValue//\r/})
- ValueArray=(${RetValue})
- ret="${ValueArray[*]}"
- return $Ret
- }
- function run_insert_sql()
- {
- run_select_sql "$1"
- return $?
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement