Help with Script using rsh and scripts within scripts

Hi,

I've written a script that runs on a Database server. It has to shutdown the Application server, do an Oracle Dump and then restart the Application server. Its been a long time since I wrote any shells scripts. Can you tell me if the scripts that I execute within my script will be executed straight after each other? Or will the shell wait till each script has finished executing before moving on to the next script?

Please see below script:

#!/bin/sh
# Script to Export Oracle tables.
# Check that this script only runs on the DBSERVER
sysname=`uname -n`
case ${sysname} in
DBSERVER) rserv="APPSSERVER" ;;
*) exit ;;
esac
line="-------------------------------------------------------------\
-----------------"

# Log File Directory
slog="/x3log/export"
runlog="/x3log/export/explog"
> ${runlog}

#Check that the parameter now has been passed to the script
if [ x${1} != "xnow" ]
then
echo "ERROR : This script should not be run unless you know how it works.\n"
echo "It will kill ALL Apps sessions and stop the Services on Apps Server "
echo "It will then perform an OracleDump.There are no 'Are you sure?'messages!\n"
echo "If you really want to export, run it again with one parameter, 'now' "
exit 1
fi
# Remote command stop APP on APPSERVER
rundat=`/usr/bin/date +%a' '%d%h%Y' '%H':'%M`
echo "${rundat} ${rserv} Shutdown X3" >> ${slog}
rsh ${rserv} /etc/rc.shutdown >> ${runlog} 2>&1

#Run script to execute export.
rundat=`/usr/bin/date +%a' '%d%h%Y' '%H':'%M`
echo "${rundat} ${sysname} Export Oracle" >> ${slog}
/x3log/export/all_exp_DB_scr.sh

# Remote comamnd to Restart APP on APPSERVER
rundat=`/usr/bin/date +%a' '%d%h%Y' '%H':'%M`
echo "${rundat} ${rserv} Start X3" >> ${slog}
rsh ${rserv} /etc/rc.APP >> ${runlog} 2>&1
#-------------------------------------------------------#
# End #
#-------------------------------------------------------#

They will execute in sequence, waiting for the previous command to complete.

In the case of the rsh ... rc.shutdown invocation, that script might background the shutdown process -- you'll have to check. For instance, on some systems, that script calls telinit 1 which initiates a shutdown. Another implementation might block until the current shell is terminated by the shutdown process.

To keep the forums high quality for all users, please take the time to format your posts correctly.

For instance, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Thank You.

The UNIX and Linux Forums

Thanks for the reply Otheus. I will check the rc.shutdown script. I'll also remember to tag my code in future :slight_smile:

Cheers