#!/bin/ksh # Invoke SQL*Plus, on Apple Mac command line. # Use gqlplus (http://sourceforge.net/projects/gqlplus) unless called with -o option. # See http://www.williamrobertson.net/documents/install-oracle10g-intelmac.html for more background. # # Limitations: host/port/servicename all hardcoded, username/password visible to other users using ps -aux. # Intended for use on single-user Mac. # # Usage: # sql -- With no arguments, invokes gqlplus /nolog (does not connect to a database) # sql un/pw -- Invokes gqlplus un/pw@//hostname:port/servicename # sql -v un/p -- Verbose option, outputs diagnostic info for troubleshooting, otherwise as above # sql -o un/pw -- Invokes sqlplus un/pw@//hostname:port/servicename # # Copyright William Robertson 2006, www.williamrobertson.net # Help yourself but don't sue me if it breaks or causes plane crashes etc. sqlplus_executable=/Applications/Application_folders/gqlplus/gqlplus verbose=N port=1521 case ${ORACLE_SID} in dev10g ) host=centosvm.starbase.local; service=${ORACLE_SID}.starbase.local ;; dev11g ) host=centos411g.starbase.local; service=${ORACLE_SID} ;; eleven ) host=vm.starbase.local; service=${ORACLE_SID} ;; * ) print -u2 "$0: missing or unlisted ORACLE_SID $ORACLE_SID"; exit 1 ;; esac while getopts ":vo" switch do case $switch in v ) verbose=Y ;; # Verbose (show shell commands as they are executed) o ) sqlplus_executable=sqlplus ;; # Use Oracle sqlplus executable * ) sqlplus_args=${sqlplus_args}$OPTARG ;; # Pass any other arguments through to SQL*Plus esac done shift $(($OPTIND - 1)) if [[ -n $1 ]]; then connectstring=${1}@//${host}:${port}/${service} [[ ${connectstring} = sys/* ]] && connectstring="${connectstring} as sysdba" shift else connectstring="/nolog" fi if [[ ${verbose} = Y ]]; then print Arguments after command-line switch processing: $* set -x fi [[ -n ${sqlplus_args} ]] && sqlplus_args="-${sqlplus_args}" exec ${sqlplus_executable} ${sqlplus_args} ${connectstring} $*