Am writing a script that uses the case statement and it is not working the way that I expect it to be. Script so far is as below.
What am expecting to happen is if the user enter neither Y or YES or N or NO, it is supposed to exit out of the script running only on_exit, otherwise, it should run everything under the MAIN section. What's happening at the moment is it is running everything under main regardless of whether it is Y or YES, N or NO or otherwise.
Not sure what am doing wrong or whether this is the expected behaviour of the script based on how I've written it so far.
Any response will be very much appreciated. Thanks in advance.
########################
# 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:]`
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.
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?
Hi
The checking of Y|YES is perfectly fine. Whatever variable you have it is local to the function. In case, if you want to have a return value, you need to use something like as shown below;
As shown above, any echo you do inside the function can be collected as the return value from the calling function. The above echo will print 25. If you have more than one echo inside the function, your $x will be a string of all the echo statements outputs inside.
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)
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)
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)
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)
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)
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)
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)
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)