![]() |
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 |
| comparing 2 files using nested for loop | vadharah | Shell Programming and Scripting | 0 | 03-01-2008 04:32 AM |
| Nested loop not running using cronjob | bihani4u | Shell Programming and Scripting | 9 | 09-26-2007 11:19 AM |
| Nested Loop to Echo Multiple Arrays | yongho | Shell Programming and Scripting | 1 | 07-12-2005 11:35 AM |
| Nested while read line loop | Rakker | Shell Programming and Scripting | 7 | 06-24-2005 07:42 AM |
| nested loop | chinog | Shell Programming and Scripting | 5 | 04-20-2005 10:45 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Variable in While Loop Nested If
Hi all,
I'm having problems with the setting a variable in a nested if statement. It doesn't seem to change even if it mets the 'if' condition. My script essentially looks for a user name from the output from a kerberos command. When I find the user name, I tried to change a variable and exit the script. I'm using sh under Fedora Core 5. Here is part of my script: #!/bin/sh #Constants and Globals USER_EXISTS=1 USER_DOESNT_EXIST=0 user_name= g_exitcode= #note: I parse the $user_name from the command line arguments #Main g_exitcode=$USER_DOESNT_EXIST kas list | while read i do echo "$i : $user_name" #compare the user_name with each entry in the kas database if [ "$user_name" = "$i" ]; then #Match found g_exitcode $USER_EXISTS break fi done exit $g_exitcode So, even if a match is found, and it enters the nested if statement and sets the g_exitcode to USER_EXISTS at that point, I always exit the script with g_exitcode=USER_DOESNT_EXIST. Sorry, I'm a little new to scripting. Any help would be appreciated 0 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|