Sponsored Content
Top Forums Shell Programming and Scripting addtion to the current script !! Post 100192 by uuser on Friday 24th of February 2006 02:34:08 PM
Old 02-24-2006
addtion to the current script !!

How can I add to the current oraenv.sh so that is an oracle_sid is passed then it won't prompt for the vaid sid and just take it. If it is not passed then do what it is doing right now ??


Code:
if [ -t 0 ]                             # Command executed from a terminal
then
        ORACLE_SID=""
        while [ -z "${ORACLE_SID}" ]
        do
                tput clear; tput rev
                echo "Valid Oracle SIDs are :"
                tput rmso
                for SID in `cat /etc/oratab|grep -v "^#"|cut -f1 -d: -s`
                do
                        echo "                  ${SID}"
                done
                DEFAULT=`cat /etc/oratab|grep -v "^#"|cut -d: -f1 -s|head -1`
                echo "\nEnter the Oracle SID you require (def: $DEFAULT): \c"
                read ANSWER
                [ "${ANSWER}" = "" ] && ANSWER=$DEFAULT
                export ORACLE_SID=`grep "^${ANSWER}:" /etc/oratab|cut -d: -f1 -s`
                export ORACLE_HOME=`grep "^${ANSWER}:" /etc/oratab|cut -d: -f2 -s`
                if [ "${ORACLE_SID}" = "" ]
                then
                        echo "\n\n              ${ANS}: Invalid Oracle SID  \c"
                        sleep 2
                fi
        done
else                                    # Set to first entry in oratab
        export ORACLE_SID=`cat /etc/oratab|grep -v "^#"|cut -d: -f1 -s|head -1`
        export ORACLE_HOME=`cat /etc/oratab|grep -v "^#"|cut -d: -f2 -s|head -1`
fi

export ORACLE_SID=$ORACLE_SID
export ORACLE_HOME=$ORACLE_HOME
export PATH=${PATH}:${ORACLE_HOME}/bin
. /home/oracle/dbaprofile.sh

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do i execute script in the current shell

How do i run a shell script or perl script with in the context of a current shell. I know that i can use command source. but we can't pass any arguments to our script if we use source command as it takes only one argement i.e filename Is there any way to run a script in the current shell... (5 Replies)
Discussion started by: Naresh Kumar
5 Replies

2. Shell Programming and Scripting

Trigger Shell Script from Current Script

Hello all, I'm new to shell programming and need some help. I would like to set up a step within a shell script to trigger another shell script to run, based on the highest return code generated in the current script. For example, if the highes return code value in the current script is less... (1 Reply)
Discussion started by: mmignot
1 Replies

3. UNIX for Dummies Questions & Answers

Determine FULL name of current script

Hi everyone, Is there a slick way to determine the FULL name of a script that is running? The variable ${0} just gives the relative path name. I guess I could just do the following: FULL_SCRIPT_NAME=${PWD}${0}Although that's pretty simple is there another way that I am missing? ... (4 Replies)
Discussion started by: msb65
4 Replies

4. Shell Programming and Scripting

Get current and parent script name

Hi, i have a script a.sh that calls b.sh Both take parameters a.sh { b.sh p1 p2 p3 } b.sh { GIVEN_CMD="`basename $0` $@" echo "${GIVEN_CMD} } Now when i run: a.sh q1 q2 It prints only a.sh q1 q2 Inside b.sh, how can i print both the script names and their parameters passed? (6 Replies)
Discussion started by: ysrini
6 Replies

5. Shell Programming and Scripting

Addtion of two numbers

for i in 1 2 3 4 5 do y='expr $i + 1'; echo $y done After running this shell script i want the output to be 2 3 4 5 6 but the result is coming as expr $i + 1 expr $i + 1 (3 Replies)
Discussion started by: Sambuddha
3 Replies

6. UNIX for Dummies Questions & Answers

Export script to current session

Hi, I have a script called bash$> cat -ev setprofile.sh alias rm='rm -i'$ $ The alias does not take effect unless i run the script as bash$> . ./setprofile.sh What do I have to do in-order to simply run (9 Replies)
Discussion started by: shifahim
9 Replies

7. Shell Programming and Scripting

Finish current script and execute next script

Hi, I've come accross a situation where I need to exit from current shell script at the same time I need to start/activate another shell script. How can I do that in KSH ?? Need help !! For example, my script is as below #!/bin/ksh paramFile="/home/someXfile.lst" ] && <<Here I... (1 Reply)
Discussion started by: R0H0N
1 Replies

8. UNIX for Advanced & Expert Users

Send current script to background

Hi scripters, I'm quite used to run commands in the background using & like in: $ myscript &But this is NOT what I'm trying to do today. What I'm trying to achieve is to run a script the normal way (without &), have my script do a little checkup and then jump to background. Something like:... (5 Replies)
Discussion started by: chebarbudo
5 Replies

9. Shell Programming and Scripting

Script to Proceed to the Next IP if the current IP hangs

Hi there, Say I have a list of IPs, I am running scripts on them. If the process hang. I want to continue with the rest of the IPs. 10.11.1.1 10.11.1.2 10.11.1.3 10.11.1.4 10.11.1.5 10.11.1.6 <-- Process Hangs here 10.11.1.7 10.11.1.8 10.11.1.9 10.11.1.10 10.11.1.11 10.11.1.12 ... (11 Replies)
Discussion started by: alvinoo
11 Replies

10. Shell Programming and Scripting

Function to get the current script name

I have a function to get the executing scripts name. Script_nm() { Parent=$( ps -f -p $PPID -o and | tail -l | sed -e 's/ *\{1,\}sh *//' | awk '{print $1}' ) If ; then Script_nm='bash_test.sh' Else Script_nm=$( basename $parent ) Fi Echo "$script_nm" Return 0 } We are calling this ... (4 Replies)
Discussion started by: srilaxman
4 Replies
service(8)						      System Manager's Manual							service(8)

NAME
service - run a System V init script SYNOPSIS
service SCRIPT COMMAND [OPTIONS] service --status-all service --help | -h | --version DESCRIPTION
service runs a System V init script in as predictable an environment as possible, removing most environment variables and with the current working directory set to /. The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT. The supported values of COMMAND depend on the invoked script. service passes COMMAND and OPTIONS to the init script unmodified. All scripts should support at least the start and stop commands. As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start com- mand. service --status-all runs all init scripts, in alphabetical order, with the status command. EXIT CODES
service calls the init script and returns the status returned by it. FILES
/etc/init.d The directory containing System V init scripts. ENVIRONMENT
LANG, TERM The only environment variables passed to the init scripts. SEE ALSO
/etc/init.d/skeleton, update-rc.d(8), init(8), invoke-rc.d(8). Jan 2006 service(8)
All times are GMT -4. The time now is 08:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy