forked from khailey-zz/oramon
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sqlplus.sh
38 lines (32 loc) · 1.03 KB
/
sqlplus.sh
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
#!/bin/ksh
function usage
{
echo "Usage: $(basename $0) <username> <password> <host> [sid] [port]"
echo " username database username"
echo " username database password"
echo " host hostname or IP address"
echo " sid optional database sid (default: orcl)"
echo " port optional database port (default: 1521)"
echo " script optional database script (defaultt: empty)"
exit 2
}
[[ $# -lt 3 ]] && usage
[[ $# -gt 6 ]] && usage
UN=$1
PW=$2
HOST=$3
SID=orcl
PORT=1521
[[ $# -gt 3 ]] && SID=$4
[[ $# -gt 4 ]] && PORT=$5
[[ $# -gt 5 ]] && SCRIPT="@$6"
sqlplus "$UN/$PW@\
(DESCRIPTION=\
(ADDRESS_LIST=\
(ADDRESS=\
(PROTOCOL=TCP)\
(HOST=$HOST)\
(PORT=$PORT)))\
(CONNECT_DATA=\
(SERVER=DEDICATED)\
(SERVICE_NAME=$SID)))" $SCRIPT