The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
variable scope shellwell Shell Programming and Scripting 3 07-15-2009 12:38 PM
variable inside variable inside loop headache hcclnoodles Shell Programming and Scripting 6 06-18-2009 05:55 PM
scope of the variable - Naga nagnatar Shell Programming and Scripting 13 04-27-2009 03:26 PM
Changing value of a variable inside a shell script kshyju Shell Programming and Scripting 1 12-12-2008 05:06 AM
replacing a number with random variable inside shell script user_prady Shell Programming and Scripting 3 09-11-2007 03:44 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-02-2009
vij_krr vij_krr is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 13
Thumbs down scope of a Variable inside shell script

hi all,

i'm using the following script,

Code:
Status=1
Function_do ()
{
while read line;
do
    if [ ` echo $line | grep 'symbol not found:' | wc -l` -eq 1 ]; then
        #echo $line
        if [ ! `echo $line | grep 'kxdfhei1' | wc -l ` -eq 1  -o  ! `echo $line | grep 'main' | wc -l ` -eq 1 ]; then
            Status=0
            echo " LINKINK ERROR "
        fi
    fi
done < ldd.log
}

Function_do
echo " Status = $Status "

OUTPUT:

Code:
LINKINK ERROR
Status = 1

What happen to the value of Status=0 that i set inside If condition? What happens if use while? the same script if i use for loop it is giving proper output.. status=0. I'm not able to understand the logic behind it. Can any one help me in this?


Regards,
Vijay

Last edited by pludi; 11-02-2009 at 03:45 AM.. Reason: code tags, please...
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0