After exit from function it should not call other function


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting After exit from function it should not call other function
# 1  
Old 10-13-2011
After exit from function it should not call other function

Below is my script that is function properly per my conditions but I am facing one problem here that is when one function fails then Iy should not check other functions but it calls the other function too So anyone can help me how could i achieve this?

iNOUT i AM GIVING TO THE SCRIPT=D1234,S12345 | ROHIT SINGH

Code:
echo -en "Enter the logmsg="
read logmsg
logmsg1=${logmsg%%|*};
echo $logmsg1 |sed "s/$/,/g"|sed 's/[ \t]*$//'>pre-commit.config
logmsg_len2=$(echo ${logmsg} | awk '{print $2}');
logmsg_suffix="|";
length()
{
cat "pre-commit.config"| awk -F'[,|]' '{for(i=1;i<NF;i++) { if ( length($i) <= 6 ) { print " success"} else { print " error";exit 1;}}}';
}
Char()
{
#echo $logmsg1
echo $logmsg1 | tr ',' '\n' | awk '{if($0~/^D/||/^S/) {print $0" starts"} else {print " Please check your input(e.g. Start it with D or S)";exit;}}'
}
Pipe()
{
if [[  "${logmsg_len2}" != "${logmsg_suffix}" ]]; then
                 echo -e "error use | symbol"
                 exit 1;
     else
   echo "success"
 fi
}
length
Char
Pipe

# 2  
Old 10-13-2011
Code:
funct1()
{
#do something
return 1 or return 0
}

funct2()
{
#do something
return 1 or return 0
}

funct3()
{
#do something
return 1 or return 0
}

funct1 || exit 1
funct2 || exit 1
funct3 || exit 1

or

Code:
funct1()
{
#do something
#if not success exit
}

funct2()
{
#do something
#if not success exit
}

funct3()
{
#do something
#if not success exit
}

funct1
funct2
funct3

The exit which you have given is within awk. So it will not exit from the script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies

2. Programming

exit function doubts

At many places in program I see exit() being called with 2 passed as parameter to it. exit(2); What does this 2 stands for? Can I get a list all such parameters to exit? (6 Replies)
Discussion started by: rupeshkp728
6 Replies

3. Shell Programming and Scripting

Replacement of exit function

I am reading multiple numbers from user and getting its respective string value from the One.txt.But while putting this text value to the two.txt file , i want to check that if this string already there in the file , if the string already exists in the two.txt file .....the string will be ignored.... (1 Reply)
Discussion started by: jalpasoni
1 Replies

4. UNIX for Advanced & Expert Users

Cannot exit from a function?

Hi, Is there a way to exit from a subcommand, which is a function in my example below? #!/bin/ksh function exitFunction { if ]; then echo "success" elif ]; then echo "failed" exit 1 # the exit problem fi exit 0 } ... (2 Replies)
Discussion started by: chstr_14
2 Replies

5. Shell Programming and Scripting

Exit from function

Hi, I just want to exit from function if some condition doesnt meet then control should go back to main program and start running from where it left.. When i used "exit" inside the function, its simply exited from entire script and it didnt run anymore.. Any idea how to do this.. Thanks... (3 Replies)
Discussion started by: nram_krishna@ya
3 Replies

6. Shell Programming and Scripting

exit from function

Hi all, My kshell code is not working, when I use a function to return something. But when I use the same function as without returning any values, it is working. Pls help me here. Code1 : func1 () { y=`echo $x | grep XXX| cut -f 2 -d ' '` if ; then exit 100 ... (2 Replies)
Discussion started by: poova
2 Replies

7. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

8. Shell Programming and Scripting

Function Call

Hi, I have a string corresponding to a function. How I can call that function without if statement? Thanks in advance. (4 Replies)
Discussion started by: Zaxon
4 Replies

9. Shell Programming and Scripting

help on function call

hello, when i call function inside awk traitement it doesn't work, i don't have error execution but i don't get result and if i call the function outside awk traitement it work well.. there's something special in awk call function?? here is the example : awk -F "," '{ {first=$1; sec=$2;... (3 Replies)
Discussion started by: kamel.seg
3 Replies

10. UNIX for Dummies Questions & Answers

EXIT from a Program not from the function..

Hi, I want a command in unix shell script which will exit my whole program, not only from the function it's using. For e.g: $1 == "m_who" && $4 == "Extrnl Vendor" { print "You don have access" exit (0); } If this error is showing on the screen, then nothing should not... (9 Replies)
Discussion started by: ronix007
9 Replies
Login or Register to Ask a Question