![]() |
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 |
| SDL doubt | royalibrahim | High Level Programming | 0 | 11-22-2007 01:49 AM |
| awk doubt.. | esham | Shell Programming and Scripting | 11 | 10-11-2007 02:24 AM |
| Simple to you not simple to me pattern matchin help | aleks001 | Shell Programming and Scripting | 0 | 07-22-2007 10:06 PM |
| Ok simple question for simple knowledge... | Corrail | UNIX for Dummies Questions & Answers | 1 | 11-28-2005 01:03 PM |
| doubt it sed | esham | Shell Programming and Scripting | 2 | 03-08-2005 01:52 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Quote:
Code:
[/tmp]$ cat test.sh #! /bin/ksh L=0 if ((L=L+1)) ; then echo $L else echo "Failed" fi; if ((L=L-1)) ; then echo $L else echo "Failed" fi; [/tmp]$ ./test.sh 1 Failed [/tmp]$ |
|
||||
|
I have a small script flow like this
#! /bin/ksh testscpt.sh pgmcc=$? if (( $pgmcc -ne 0 && $pgmcc -ne 99 )) then echo "Correct condition check" else echo "Failed" fi FIrst, I am getting syntax error with the if condition. Second, the testscpt.sh always returns 0. What will happen to this check if the testscpt.sh returns value other than 0 or 99. |
|
|||||
|
Quote:
if (( $pgmcc -ne 0 && $pgmcc -ne 99 )) should be if (( $pgmcc -ne 0 || $pgmcc -ne 99 )) I think you should change ((expr)) to [[expr]] to satisfy your requirements. |
|
||||
|
THe testscpt.sh returns multiple return codes based on the error conditions. But it returns only one code at any particular time. We had a problem with the script a few days back and on analysing found the issue due to this check. THe script shown above is a small representation of the the actual code.
Normally, the testscpt.sh always returns 0, but a few days back, it failed due to DB issues and returned 1. The if condition should have caught that, but it failed and it led to lot of processing issues. We are currently planning to make changes to this part of the code. Even, we are not sure why the '&&' has been included. Is it due to the way (( )) evaluates its expression. Thanks for your inputs. We were lost/perplexed from the morning. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|