`How to escape characters in password in bash script?
S
S
shevlyakovn2016-01-06 01:10:57
linux
shevlyakovn, 2016-01-06 01:10:57

How to escape characters in password in bash script?

I want to write a simple script using bash to recover a password, there is a line
echo `mysql -u$LOGIN_NAME -p$LOGIN_PASSWD $DB_NAME < backup/$DB_NAME.sql`;
The matter is that some bases are not recovered since. the password variable can have characters &, $, etc. That is, I need a similar password [email protected]&@%82 to turn into [email protected]\&@\%82
In my case, the command is sent in the script like this
mysql -uNAME [email protected]&@%82 DB_NAME < backup/
DB_NAME.sql mysql -uNAME
[email protected]\&@\%82 DB_NAME < backup/DB_NAME.sql

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pavlinux, 2016-01-06
@shevlyakovn

'echo `mysql -u"$LOGIN_NAME" -p"$LOGIN_PASSWD" "$DB_NAME" < backup/"$DB_NAME.sql"`;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question