Using 'break' is breaking my leg - HELP!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using 'break' is breaking my leg - HELP!
# 1  
Old 03-20-2009
Using 'break' is breaking my leg - HELP!

Hello,
I am having problems breaking out a while loop and then trying to call another method afterwords, the 'FirstMain' method is never called once I break. How can get teh code to do this?
I have been trying since Yesterday and no joy...Plan B 'SUICIDE' Smilie

FirstMain()
{
.......does somthing
}

SecondMain()
}
echo "User enter somethin"
read x

while read line ; do
if [.. something..] ; then
...do something 1...
elif [.. something..] ; then
...do something 2...
else
break
FirstMain
fi
done < somefile.txt

echo "glad I am out"
}
# 2  
Old 03-20-2009
Hello there,

Obviously when you put break before your function call, you exit the loop before being able to call your function. As a result you will have to interchange break and function call and to put the function call before break.

Regards,
Smilie
# 3  
Old 03-20-2009
Thank you dariyoosh,
That works, somtimes the simpliest of stoff is overlooked.
The code now calls the other method (backup) but it does not wait for the user to enter anything


backup() {
echo "\nTest day not found, would you like to try again? [Y/N] : "

typeset -u pp # Changes the entered value to uppercase
read ans
pp=$ans

if ["$pp" = "Y"] ; then
main
elif ["$pp" = "N"] ; then
echo "\n ******** GOODBYE ************ \n"
else
echo "\nUnrecognised entry \n"
fi
}
# 4  
Old 03-20-2009
New to scripting

Sorry posted the concern at wrong thread
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Breaking a pipe

Here's my code - for File in "${Files}"; do uuencode "${File}" "$(basename ${File} 2>&-)" 2>&-; done | mailx -s "subject" "a@b.c" Now I want to know if there a way to *not* send an email if the "Files" variables turns out to be blank. Any suggestions? Also, just to clarify, I... (4 Replies)
Discussion started by: nexional
4 Replies

2. Shell Programming and Scripting

Breaking out of an if statement

i have a nested if statement. i need to check for a condition (highlighted in red below). if condition is true, i need the if statement to break out of the statement and then return to the if statement section i have highlighted in blue. is this possible? if ; then #return here ... (6 Replies)
Discussion started by: SkySmart
6 Replies

3. Shell Programming and Scripting

Can't Commit Directory... is this guy pulling my leg?

Hello, I hired a coder a couple weeks ago to develop 3 small modules for a popular CMS. I created Github repos for each module so as to manage the code and allow others to download it at will. The CMS in question is structured in such a way that each module is housed in its own... (2 Replies)
Discussion started by: fern
2 Replies

4. Shell Programming and Scripting

BASH: Break line, read, break again, read again...

...when the lines use both a colon and commas to separate the parts you want read as information. The first version of this script used cut and other non-Bash-builtins, frequently, which made it nice and zippy with little more than average processor load in GNOME Terminal but, predictably, slow... (2 Replies)
Discussion started by: SilversleevesX
2 Replies

5. Shell Programming and Scripting

breaking for loop

Dear Friends, Here I need your guidance once again. I have for loop which check all files in a folder for a particular string. If the string is found in a file it returns value other than 0 else returns 0 value in variable t2. At times the string which we are looking for is in first file... (1 Reply)
Discussion started by: anushree.a
1 Replies

6. Shell Programming and Scripting

Breaking up a file

Hi, I have a file that looks like this - lets call it fileA >hhm2 IIIIIIIIILLLLLLLMMMMMMMMMNNNNNNNNNNGGGGGGHHHHHHHH >hhm4 OOOOOKKKKKKKKMMMMMHHHHHLLLLLLLLWWWWWWWWWWW >hhm9 OOOOOOOIIIIIIIIIKKKKKKKKKMMMMMHHHHHHHHHHHLLLLLLLLLL So the file is pretty straight forward. The name is indicated... (2 Replies)
Discussion started by: phil_heath
2 Replies

7. Shell Programming and Scripting

Breaking out of a pipe

I have the following command in a Bash shell script: who | grep -w $1 | some other commands If grep fails, an error message is displayed. How do I test if grep fails and still be able to pipe it's output to the rest of the commands? I have the following solution: a=`who | grep -w $1`... (3 Replies)
Discussion started by: oinkl
3 Replies

8. Shell Programming and Scripting

Breaking line

My input file is like USER_WORK.ABC USER_WORK.DEF I want output file like ABC DEF (4 Replies)
Discussion started by: scorp_rahul23
4 Replies

9. Linux

breaking out of while loop

Hi , I am running this script ( pasting only error code ) to generate some ddl definition for tables . But what I want is to break out of the db2look part when the base_table is not like DIM_$TN or FACT_$TN . After this it should come back to while loop to read the next TN . I read the other... (3 Replies)
Discussion started by: capri_drm
3 Replies
Login or Register to Ask a Question