Sponsored Content
Full Discussion: Help with case and exit
Top Forums Shell Programming and Scripting Help with case and exit Post 302418085 by newbie_01 on Monday 3rd of May 2010 02:39:28 AM
Old 05-03-2010
Quote:
Originally Posted by guruprasadpr
Hi
There is no exit status handling after the call to the function check_argument, and hence report_01 and report_02 is also getting called. Handle the exit status of check_argument and also send some specific status in the check_argument function.

Thanks
Guru.

Hi Guru,

Thanks for your response.

From your suggestion, that means I've made the wrong assumption that the exit command will exit out of the script.

BTW, is my checking under case correct though, i.e. the Y|YES thingy?

I put some echo line for testing and am expecting the echo of ${v_database_set} should show whatever I enter when prompted by the read v_database_set line. How come that does not seem to be the case? That is, the value of v_database_set is null/empty? Am expecting it should show Y, N or whatever I enter when prompted by the read command. It seemed like the variable is local to check_argument, is that how it is supposed to be?

Output from running the script:

Code:
+---------------------------------------------------------------------+

Start running <- x ->
DATE : Mon May  3 16:25:52 EST 2010


+----------------------------------------------+
 Database running on vinhns-nwp01 :
 DATE : Mon May  3 16:25:52 EST 2010
+----------------------------------------------+

Or you set on the current database to check [Y/N] ??? x

v_database_set --> X ...
Invalid answer !!! Exiting ...


+---------------------------------------------------------------------+
Search and remove tmp files on /oracle/BIP/102_64/OZONE/scripts/sql ...
         /oracle/BIP/102_64/OZONE/scripts/sql
+---------------------------------------------------------------------+

ls: x.tmp.*: No such file or directory

Check the report file -> x.report

v_database_set -->  ...

Running report_01 ...


Running report_02 ...


+---------------------------------------------------------------------+
Search and remove tmp files on /oracle/BIP/102_64/OZONE/scripts/sql ...
         /oracle/BIP/102_64/OZONE/scripts/sql
+---------------------------------------------------------------------+

ls: x.tmp.*: No such file or directory

Check the report file -> x.report



Echo placed on the script:


Code:
########################
# SUB : check_argument #
########################
check_argument()
{
   echo "+----------------------------------------------+"
   echo " Database running on `hostname` :"
   echo " DATE : `date`"
   echo "+----------------------------------------------+"

   echo ""
   echo "Or you set on the current database to check [Y/N] ??? \c"
   read v_database_set
   echo ""
   v_database_set=`echo ${v_database_set} | tr [:lower:] [:upper:]`

  echo "v_database_set --> ${v_database_set} ..."
   case ${v_database_set} in
      Y|YES) v_db=$ORACLE_SID
             echo ""



......
......
......

########
# MAIN #
########

on_start                | tee -a ${this_report}
check_argument  | tee -a ${this_report}

echo "v_database_set --> ${v_database_set} ..."
sleep 5

report_01               | tee -a ${this_report}
report_02               | tee -a ${this_report}

on_exit                 | tee -a ${this_report}


Last edited by pludi; 05-03-2010 at 01:35 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies

2. UNIX for Dummies Questions & Answers

Where can I find a list of exit codes? (Exit code 64)

I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Discussion started by: jkuchar747
3 Replies

3. Shell Programming and Scripting

Script needed to select and delete lower case and mixed case records

HELLO ALL, URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE. FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY and the CITY column records will be: Newyork washington ... (1 Reply)
Discussion started by: abhilash mn
1 Replies

4. Shell Programming and Scripting

exit from case - called in a function

Hello Experts, I am building a shell where I need to use case structure. The structure is in a function as in the sample code below: # Shell mySh #!/bin/sh doThis(){ var=$1 case "$var" in IT) echo "ok 1 $var" ;; ... (7 Replies)
Discussion started by: hkansal
7 Replies

5. Shell Programming and Scripting

Not able to exit from case statements

Hi all, I wrote the following simple shell script to perform addition, subtraction, multiplication and division. In the below program, i am not able to exit from the script Shell Script ----------- #!/bin/sh bgcal() { cal="" echo "Enter the Option Number: \c" read cal if then... (3 Replies)
Discussion started by: uxpassion
3 Replies

6. Shell Programming and Scripting

sed ignoring case for search but respecting case for subtitute

Hi I want to make string substitution ignoring case for search but respecting case for subtitute. Ex changing all occurences of "original" in a file to "substitute": original becomes substitute Origninal becomes Substitute ORIGINAL becomes SUBSTITUTE I know this a little special but it's not... (1 Reply)
Discussion started by: kmchen
1 Replies

7. Shell Programming and Scripting

[Solved] Change Upper case to Lower case in C shell

Is there a command that can switch a character variable from UPPER case to lower case? like foreach AC ( ABC BCD PLL QIO) set ac `COMMAND($AC)` ... end Thanks a lot! (3 Replies)
Discussion started by: rockytodd
3 Replies

8. Shell Programming and Scripting

Conversion from Upper Case to Lower Case Condition based

Hello Unix Gurus : It would be really appreciative if can find a solution for this . I have records in a file . I need to Capitalize the records based on condition . For Example i tried the following Command COMMAND --> fgrep "2000YUYU" /export/home/oracle/TST/data.dat | tr '' ''... (12 Replies)
Discussion started by: tsbiju
12 Replies

9. Shell Programming and Scripting

Change first letter of a word from lower case to upper case

Hi all, I am trying to find a way to change first letter in a word from lower case to upper case. It should be done for each first word in text or in paragraph, and also for each word after punctuation like . ; : ! ?I found the following command sed -i 's/\s*./\U&\E/g' $@ filenamebut... (7 Replies)
Discussion started by: georgi58
7 Replies
All times are GMT -4. The time now is 02:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy