pedrommone
April 17th, 2013, 07:01 PM
When I try to cat a block and save it, some function are executed, like this one
USER_ID=$(mysql -u $DB_USER -p$DB_PASS -h$DB_HOST $DB_NAME --disable-column-names -e "SELECT id FROM users WHERE username='$USER';")
My bash is the follow
#!/bin/bash
script="tunnel-bootstrap.sh"
temp=`getopt -l id:,name:,ip:,type:,host:,user:,pass:,db: -n "$0" -- '' "$@"` || exit 1
eval set -- optname optval "$temp"
declare -A opt
while shift 2; do
case $1 in
--id|--name|--ip|--type|--host|--user|--pass|--db) opt[${1#--}]="$2";;
esac
done
cat <<EOF >"$script"
#!/bin/bash
############################
# CARREGA DADOS DO SERVIDOR
############################
SERVER_ID=${opt[id]}
SERVER_NAME="${opt[name]}"
SERVER_IP="${opt[ip]}"
SERVER_TYPE="${opt[type]}"
DB_HOST="${opt[host]}"
DB_USER="${opt[user]}"
DB_PASS="${opt[pass]}"
DB_NAME="${opt[db]}"
############################
# INICIO DO CHECK-IN
############################
if [ $USER == "ubuntu" ]; then
return
fi
trap '' 2
USER_ID=$(mysql -u $DB_USER -p$DB_PASS -h$DB_HOST $DB_NAME --disable-column-names -e "SELECT id FROM users WHERE username='$USER';")
EOF
Thanks in advance.
USER_ID=$(mysql -u $DB_USER -p$DB_PASS -h$DB_HOST $DB_NAME --disable-column-names -e "SELECT id FROM users WHERE username='$USER';")
My bash is the follow
#!/bin/bash
script="tunnel-bootstrap.sh"
temp=`getopt -l id:,name:,ip:,type:,host:,user:,pass:,db: -n "$0" -- '' "$@"` || exit 1
eval set -- optname optval "$temp"
declare -A opt
while shift 2; do
case $1 in
--id|--name|--ip|--type|--host|--user|--pass|--db) opt[${1#--}]="$2";;
esac
done
cat <<EOF >"$script"
#!/bin/bash
############################
# CARREGA DADOS DO SERVIDOR
############################
SERVER_ID=${opt[id]}
SERVER_NAME="${opt[name]}"
SERVER_IP="${opt[ip]}"
SERVER_TYPE="${opt[type]}"
DB_HOST="${opt[host]}"
DB_USER="${opt[user]}"
DB_PASS="${opt[pass]}"
DB_NAME="${opt[db]}"
############################
# INICIO DO CHECK-IN
############################
if [ $USER == "ubuntu" ]; then
return
fi
trap '' 2
USER_ID=$(mysql -u $DB_USER -p$DB_PASS -h$DB_HOST $DB_NAME --disable-column-names -e "SELECT id FROM users WHERE username='$USER';")
EOF
Thanks in advance.