- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsqlscript.sh
More file actions
Latest commit
executable file
·43 lines (37 loc) · 1.06 KB
/
Copy pathsqlscript.sh
File metadata and controls
executable file
·43 lines (37 loc) · 1.06 KB
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
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
delimiter=";"
DIR="$(cd"$( dirname "${BASH_SOURCE[0]}")"&&pwd)"
OPTIND=1
functiongenerateAlias {
if [ !-f~/.bash_aliases ];then
touch ~/.bash_aliases
echo"alias sqlscript=$DIR/sqlscript.sh">~/.bash_aliases
else
grep "sqlscript"~/.bash_aliases
if [ !"$?"="0" ];then
echo"alias sqlscript=$DIR/sqlscript.sh">>~/.bash_aliases
else
echo"alias already exists"
fi
fi
}
if [ !-f~/.sqllogindata ];then
echo">No login file found in home, creating a new one."
echo">WARNING: use only in secure environments, data is stored in plain text"
echo">Please enter your username"
read username
echo">Hi $username, nice to meet you."
echo">Please enter your password."
read -s password
echo"${username}${delimiter}${password}">~/.sqllogindata
fi
#handle cl arguments
whilegetopts"a" opt;do
case"$opt"in
a) generateAlias
;;
esac
done
login="$(cat ~/.sqllogindata)"
IFS=\\$delimiterread -a loginarr <<<"$login"
mysql -h 193.196.143.168 -u "${loginarr[0]}" -p"${loginarr[1]}"