![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Variables scope. | dinjo_jo | Shell Programming and Scripting | 13 | 09-10-2008 07:03 AM |
| Scope of AIX | abhishek27 | AIX | 4 | 06-19-2008 09:49 AM |
| create variable name based on another variable's value | benefactr | Shell Programming and Scripting | 2 | 11-01-2007 12:27 PM |
| How do one evaulate a variable's value if it is number or not | suman_jakkula | Shell Programming and Scripting | 1 | 04-20-2007 01:06 AM |
| scope | sundaresh | High Level Programming | 7 | 06-28-2006 11:19 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
problem with shell variable's scope
Hi,
I am stuck while developing a shell sub-routine which checks the log file for "success" or "failure". The subroutine reads the log file and checks for key word "success", if found it set the variable (found=1). It returns success or failure based on this variable. My problem is, I can see the variable being set to 1 (success scenario) but once it comes outside the while loop the value is reset to 0. Here is the my logCheck function, please let me know where I am wrong. function logCheck { found=0; #sets to 1 if "success" is found cat ${OUTPUT_LOG} | while read line do temp=`echo $line|grep "${SUCCESS_MESSAGE}"` if [ $? -eq 0 ];then found=1 <-- value is 1 here echo "string is found" echo "found value inside while is : $found" fi done echo "found value outside while is $found" <-- found is 0 in all case if [ $found = 1 ];then return $SUCCESS; else return $FAILURE fi } //output for success scenario: string is found found value inside while loop : 1 found value outside while loop is 0 |
|
||||
|
Thanks a lot Johnson.. have incorporated the changes and its working fine now...
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|