Skip to content

Commit 082ae4e

Browse files
Create Using "Expect"
1 parent 47d26da commit 082ae4e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Using "Expect"

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[ ! -e /usr/bin/expect ] && { apt-get -y install expect; }
2+
SECURE_MYSQL=$(expect -c "
3+
4+
set timeout 10
5+
spawn mysql_secure_installation
6+
7+
expect \"Press y|Y for Yes, any other key for No: \"
8+
send \"n\r\"
9+
expect \"Change the password for root ? ((Press y|Y for Yes, any other key for No) : \"
10+
send \"n\r\"
11+
expect \"Remove anonymous users? (Press y|Y for Yes, any other key for No) : \"
12+
send \"y\r\"
13+
expect \"Disallow root login remotely? (Press y|Y for Yes, any other key for No) : \"
14+
send \"y\r\"
15+
expect \"Remove test database and access to it? (Press y|Y for Yes, any other key for No) : \"
16+
send \"y\r\"
17+
expect \"Reload privilege tables now? (Press y|Y for Yes, any other key for No) : \"
18+
send \"y\r\"
19+
expect eof
20+
")
21+
22+
echo "$SECURE_MYSQL"

0 commit comments

Comments
 (0)