-
Notifications
You must be signed in to change notification settings - Fork 248
/
Copy pathmysqltui
33 lines (22 loc) · 1 KB
/
mysqltui
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
TITLE="MySQL Client"
HOST=$(whiptail --title "$TITLE" --menu "MySQL Host" 22 50 8 \
"127.0.0.1" "localhost" \
"172.16.0.1" "MySQL Master" \
"172.16.0.2" "MySQL Slave 1" \
"172.16.0.3" "MySQL Slave 2" \
3>&1 1>&2 2>&3)
USER=$(whiptail --inputbox "MySQL User:" 8 60 --title "$TITLE" 3>&1 1>&2 2>&3)
PASSWD=$(whiptail --title "$TITLE" --passwordbox "MySQL Password:" 8 60 3>&1 1>&2 2>&3)
#DATABASE=$(mysqlshow -h$HOST -u$USER | egrep -o "|\w(.*)\w|" | grep -v "Databases" |awk '{print "\""$1"\" \""$1"\""}')
#DATABASE=$(mysqlshow -h$HOST -u$USER | egrep -o "|\w(.*)\w|" | grep -v "Databases" |awk "{print \"$1\" \"$1\"}")
#DB=$(whiptail --title "$TITLE" --menu "MySQL DATABASE" 22 50 8 $DATABASE 3>&1 1>&2 2>&3)
DATABASE=$(whiptail --inputbox "MySQL Database:" 8 60 --title "$TITLE" 3>&1 1>&2 2>&3)
echo $HOST $USER $PASSWD $DATABASE
mysql -h$HOST -u$USER -p$PASSWD $DATABASE
exitstatus=$?
if [ $exitstatus = 0 ]; then
echo "User selected Ok and entered"
else
echo "User selected Cancel."
fi