-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathsqlplus.sh
More file actions
41 lines (36 loc) · 1.14 KB
/
sqlplus.sh
File metadata and controls
41 lines (36 loc) · 1.14 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
#!/bin/ksh
#
# simple shell script to connect to SQL*plus
# cool thing is using it to check SQL*net connection settings
#
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