Problem in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in script
# 1  
Old 12-16-2012
Problem in script

I am writing a shell script which inside it execute a script --> start_all_oracle

it echo a message when executed --> do you wish to remove the log and pinlog files. we have to reply y/n. while executing directly we can give our option, but inside script how can I put the value as 'n' so execution will be successful


below is code.


Code:
#!/bin/sh
#
#       @(#) % %
#
#       Copyright (c) 1996 - 2006 Oracle. All rights reserved.
#
#       This material is the confidential property of Oracle Corporation or its
#       licensors and may be used, reproduced, stored or transmitted only in
#       accordance with a valid Oracle license or sublicense agreement.
#

VERSION=7.4
PATH=/usr/bin:/bin:${PATH}

PINDIR=/opt/app/portal/7.4/pin
LOGDIR=/var/opt/app/portal/7.4/pin

START_LIST="dm_oracle dm_oracle1 dm_ifw_sync"


if [ -d ${LOGDIR} ]; then
        for d in ${START_LIST} ; do
                if [ -f "${LOGDIR}/${d}/${d}.log" ]; then
                        any="y"
                fi
                if [ -f "${LOGDIR}/${d}/${d}.pinlog" ]; then
                        any="y"
                fi
        done
fi


if [ "${any}" ]; then
        echo "do you wish to remove the log and pinlog files?\c"
        read ans
        case ${ans} in
        y|Y)    echo "removing old log files...\c"
                rm -rf ${LOGDIR}/*/*log*
                echo "done"
                ;;
        n|N)    echo "leaving log files alone"
                ;;
        q|Q)    exit 0
                ;;
        *)     echo "eh? [y/n/q]"
                exit 0
                ;;
        esac
fi

for d in ${START_LIST} ; do
        if [ -f "${PINDIR}/bin/start_${d}" ];then
                ( cd ${PINDIR}/bin ; ./start_${d} )
        fi
done

# get rc from cm startup
exit $?

Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 12-16-2012 at 04:06 PM.. Reason: code tags, please!
# 2  
Old 12-16-2012
As far i know
Code:
read

command will wait for user input..I guess it will be good idea to change this section. For example if you give yes it will do the task and if their is no yes option it will move on next step with the help of
Code:
$?

symbol
# 3  
Old 12-16-2012
Vikram, I understand its functionality, but when a wrapper script call this script than how input will be provided

it means that script will wait until we won't provide input which should not happen, is there any way we can pass parameter y/n during script execution ?

my script part is like this which means it will not come out of loop until the script execute completly

Code:
start_all_oracle
##checking process for all the DM's

sleep 30
backend_dm_value=`grep "dm dm_n_be" $PIN_HOME/sys/dm_oracle/pin.conf|grep -v "^#"|cut -d" " -f4`
count=`ps -ef|egrep dm_oracle$|grep -v grep|grep -w $id|wc -l`

until [ $count -ge $backend_dm_value ]
do
        sleep 5
        count=`ps -ef|egrep dm_oracle$|grep -v grep|grep -w $id|wc -l`
done

Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 12-16-2012 at 05:54 PM.. Reason: once AGAIN - please use code tags!
# 4  
Old 12-16-2012
Code:
start_all_oracle <<EOF
y
EOF

# 5  
Old 12-16-2012
Yes it does work...thanks a ton
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in calling a script inside a script

Hi team, I have a script in different folder. Now i want to call that script and execute that script from that path alone. My code is #!/bin/bash wname=yahoo PATH='/opt/IBM' wac=`/usr/bin/ls $PATH | /usr/bin/grep "$wname"` STOP=`/usr/bin/find $PATH/$wac -type f -name "stop.sh"`... (8 Replies)
Discussion started by: natraj005
8 Replies

2. Shell Programming and Scripting

Shell script newbie, what is problem with my script?

Hello, Ubuntu server 11.10 can anybody help what is problem with my shell script? #!/bin/bash #script to find out currently logged on user is root or not. if ] then echo "You are super" else echo "You are awesome!" fi When I run script, I get following output ./uid: line 3: I... (4 Replies)
Discussion started by: kaustubh
4 Replies

3. Shell Programming and Scripting

Problem while calling a script within a script

Hi , I have moduled my scripts in three scripts . From First script i am calling second and from second i am calling third for some check . Problem is with the third script call. ---In second script EXP ='test.\abc.\Server.*abc.xml.*' pid=$($HOME/bin/checkpid $EXP) --Third... (2 Replies)
Discussion started by: amrishn
2 Replies

4. Shell Programming and Scripting

Problem running a program/script in the background from a script

Hi all, I have a script that calls another program/script, xxx, to run in the background. Supposedly this program at most should finish within five (5) minutes so after five (5) minutes, I run some other steps to run the script into completion. My problem is sometimes the program takes... (5 Replies)
Discussion started by: newbie_01
5 Replies

5. Shell Programming and Scripting

Problem with a script

Hi everyone, I got a problem with a script. What it's supposed to do is: to take as arguments a directory name <dir> and a dimension (in byte) <dim>; if <dir> exists, to write name and dimension of every regular file within it that sizes lesser than <dim> in regFileList. Nothing happens... (10 Replies)
Discussion started by: Luke Bonham
10 Replies

6. UNIX for Dummies Questions & Answers

Problem with script

Hello All. I have a script that is suppossed to start up a daemon but when executed, simply hangs. Could you please take a look and let me know where the problem might be? TIA ################################################################### # # SCRIPT: dstart3000.sh # Bring up the Domain... (6 Replies)
Discussion started by: grin1dan
6 Replies

7. Shell Programming and Scripting

call shell script from perl cgi script problem

hi,, i have perl scipt with line : system('./try.sh $t $d $m'); in shell scipt try.sh i have the line: echo $1 its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies

8. Shell Programming and Scripting

ssh script problem problem

Hi Please help me with the following problem with my script. The following block of code is not repeating in the while loop and exiting after searching for first message. input_file ========== host001-01 host001-02 2008-07-23 13:02:04,651 ConnectionFactory - Setting session state... (2 Replies)
Discussion started by: pcjandyala
2 Replies

9. Shell Programming and Scripting

Help. Script problem

hey guys. i have a bunch of programs in a script that needs to run as root and the rest as another user, we'll call him gabriel. now, in this script, i want to run the first few lines as root. now, how do i, after running as root, tell the script to run the remaining lines as the user gabriel?... (3 Replies)
Discussion started by: Terrible
3 Replies

10. UNIX for Dummies Questions & Answers

Problem starting a script from a 'main'-script

Please Help! :o I have a main script (ksh) where another script is called (convert_picture). Normally this works ok, but since some changes has been made on the unix-server (I dont know what :( ) suddenly it doesnt work anymore: i get an error message: ksh: convert_picture not found. I am... (3 Replies)
Discussion started by: Rakker
3 Replies
Login or Register to Ask a Question