Created
February 7, 2017 16:03
-
-
Save aipi/75a9c68c50931d0ee584ef883cad31e6 to your computer and use it in GitHub Desktop.
MySQL expect script to enter into database to avoid to insert sudo password and database password all the time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Instead use "mysql -u root -p" and put your sudo password and mysql password use this expect script: | |
#!/usr/bin/expect -f | |
#create an alias sql="/Users/macbookpro/Desktop/myProject/mysql-enter.sh" | |
#To know more about expect: http://www.admin-magazine.com/Articles/Automating-with-Expect-Scripts | |
spawn mysql -u root -p | |
expect { | |
"Password:" { | |
send "sudo_password\r" | |
} | |
"Enter password:" { | |
send "database_password\r" | |
} | |
} | |
expect { | |
"Password:" { | |
send "sudo_password\r" | |
} | |
"Enter password:" { | |
send "database_password\r" | |
} | |
} | |
interact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment