bash - shell EOF doesn't work with mysql command -



bash - shell EOF doesn't work with mysql command -

i changed "'" , "`" '"', errors gone still not right edit code , errors below

part of shell script this

#!/bin/bash echo alter $1 database echo "input database password:" read dbpasswd if [ $1="aa" ]; echo "input old aa ip:" read oldaaip echo "input new aa ip:" read newaaip mysql -uroot -p$dbpasswd << eof utilize test_db update "test_controller" set node_ip = "$newaaip" node_ip="$oldaaip"; update "test_cluster" set admin_ip = "$newaaip" admin_ip="$oldaaip"; update "test_physical_volume" set connect_path ="$newaaip" connect_path ="$oldaaip"; commit; eof

and got next error after ./updatedb.sh aa

change aa database input database password: 123456 input old aa ip: 1.1.1.1 input new aa ip: 1.1.1.2 error 1064 (42000) @ line 2: have error in sql syntax; check manual corresponds mysql server version right syntax utilize near '"test_controller" set node_ip = "1.1.1.2" node_ip="1.1.1.1"' @ line 1

would tell me why happens?

backtick not quotation sign, text between backticks evaluated. bash trying evaluate command between backticks before global command.

for table name don't need escape table name because it's not reserved name. if need it, have escape backticks using \ caracter.

mysql bash shell

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -