Shell script to invoke db startup/shutdown


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to invoke db startup/shutdown
# 1  
Old 08-12-2008
Shell script to invoke db startup/shutdown

Hi all,

I have a shell script which does db shutdown ..the script snippet which does this is as follows:

function call_sql_plus {
${SQLPLUS:-sqlplus} -s /nolog <<EOF
EXIT;
EOF
if [ $? -ne 0 ]
then
echo "Error occurred while calling sqlplus "
exit 2
fi
}

# Check for the Valid inputs
if [ "$1" = "" ] ; then
echo "ERROR: Invalid Input parameter"
echo "Usage: npdbstartstop.sh start/stop"
return
fi

# To set the Oracle variable, run the .profile
#su - ora10g
# Set the DB Conf details
echo "Set the ORACLE configurations"
. /software/np/db/scripts/dbenv.conf
echo $ORACLE_SID
if [ "$1" = "stop" ] ; then
echo "****** SHUTDOWN OPTION IS SELECTED... Connecting to DB..."
echo "****** SHUTDOWN OPTION SELECTED... ORACLE IS GOING DOWN IMMEDIATELY *********"
call_sql_plus
connect /as sysdba
shutdown immediate

---------------------------------------------------


all the oracle related env variables are set, including ORACLE_SID.
The problem with the above script is, it is getting into the sqlplus prompt and connecting as sysdba. But 'shutdown immediate' is not recognising as proper db shutdown command.

It is taking it as unix machine shutdown command.

Pls post ur valuable suggestions, how can i execute the above shell script in sqlplus context?

With Warm Regards,
Krishna
# 2  
Old 08-12-2008
Why dont you again use "here document" method and fire it on sqlplus prompt.

- nilesh
# 3  
Old 08-13-2008
can u pls give me some example of that?

My requirement is that the, db shutdown should be invoked through executing shell script.
# 4  
Old 08-13-2008
The commands are not being sent to sqlplus at all; you should use the same technique as in the call_sql_plus function using <<EOF to wrap the commands; this is called a "here document", as quick Googling for the term would have told you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Startup and shutdown script

Hi all, I'm writing a script to stop & start oracle: su - oracle -c "sqlplus / as sysdba" -c "shutdown immediate">> ${log} 2>&1 The {log} refers to the log file. The part in bold gives error: /usr/sbin/shutdown: Only root can run /usr/sbin/shutdown Pls suggest how to correct this. ... (5 Replies)
Discussion started by: frum
5 Replies

2. AIX

Auto startup and shutdown in AIX

Hi All, I would like to schedule auto IPL (shutdown and start-up) by using a shell script. Can you please give me some idea? want to test on my lab box first. shell script should bring AIX LPAR down and then need to start/activate the LPAR after 30 min any idea is highly... (3 Replies)
Discussion started by: System Admin 77
3 Replies

3. Shell Programming and Scripting

Automatic shutdown and startup of Tomcat in Solaris

Dear Experts , I want to stop and Start tomcat at the time of shutdown and startup of our server . I was trying to stop tomcat with following command # su - dm -c "/export/home/Finder/FinderWeb/jakarta-tomcat-3.3.1a/bin/shutdown.sh" but i am getting following error. Please suggest .... (1 Reply)
Discussion started by: Amit.saini333
1 Replies

4. AIX

Startup/shutdown scripts in AIX

hi, If we place Sxx (startup script) and Kxx(shutdown script) in /etc/rc.d/rc2.d,then it would start and stop automatically(assume they are linked to other script that actually starts/stops). is there really a link needed here to /etc/rc.d/init.d? if not,what is the use of this directory..?... (1 Reply)
Discussion started by: to_bsr
1 Replies

5. Solaris

Startup and shutdown a server

Are rc scripts executed serially or all at the same time. Is there a way to see this happen? A log file or the syslogd? This is Solaris 10. (2 Replies)
Discussion started by: djehresmann
2 Replies

6. UNIX for Dummies Questions & Answers

Where is the shutdown/startup log?

Having difficulty trying to locate startup and shutdown messages. I had a bunch of servers shutdown over the weekend (due to a scheduled power outage) and upon reboot a lot of the filesystems weren't mounted and several processes weren't started... I checked /var/adm/messages and can't locate... (2 Replies)
Discussion started by: jamie_collins
2 Replies

7. Shell Programming and Scripting

How can i invoke SU command in shell script

Hi All , i am trying to switch user (from unix1 to unix 2 ) The user will give me the input and also the password . also how can i login into with the password . itried several attempts . no luck Can any one help on this !!! (4 Replies)
Discussion started by: raghav1982
4 Replies

8. SuSE

How to record shutdown/startup messages

The wtmp file records all logins and logouts. Its format is exactly like utmp except that a null user name indicates a logout on the associated terminal. Furthermore, the terminal name "~" with user name "shutdown" or "reboot" indicates a system shutdown or reboot and the pair of terminal names... (1 Reply)
Discussion started by: Laksmi
1 Replies

9. AIX

Startup/Shutdown scripts

I understand that by putting in entries into the /etc/inittab file. We can actually call the our scripts during startup. mkitab "start_server:2:once:sh /scripts/startserver.sh" Would the system wait for startserver.sh finish executing before it goes to another entry? and how long would it... (1 Reply)
Discussion started by: vincente
1 Replies

10. Shell Programming and Scripting

how to invoke shell script

hi everybody, i learning unix now only.Can u pls guide me in invoking a shell script.Actually i need to know how to write the command for invoking the shell script.Suppose the shell file name is count , then how i will write the command. thanks (1 Reply)
Discussion started by: gopa_mani
1 Replies
Login or Register to Ask a Question