help with korn shell if command
|
Original Message
|
Name: john k
Date: January 29, 2003 at 08:45:25 Pacific
Subject: help with korn shell if commandOS: UNIXCPU/Ram: ALPHA, lots |
Comment: I am trying to read in 2 values from user input prompt, and if the second value is less than the first, I would like to re-prompt the user for value 2. I can't seem to get my statements to work correctly! they are like: echo "Enter low div: \c" read div1 echo "Enter high div: \c" read div2 if [ $div1 > $div2 ] then echo "high div is less than low div!!!" echo "Please reenter high div: \c" read div2 fi The comparison always fails, no matter if the second value is larger than the first value! Any help would be appreciated! Thanks John K
Report Offensive Message For Removal
|
|
Response Number 2
|
|
Reply: (edit)Here it is in Korn shell syntax: integer low high while ! (( low high )) do read low?"Enter a number: " read high?"Enter a higher number: " (( low high )) || print -u2 "No, ${high} is not higher than ${low}. Please re-enter." done print Low: $low print High: $high
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
|
Reply: (edit)Messageboard swallowed the less-than characters. That should be: integer low high while ! (( low high )) do read low?"Enter a number: " read high?"Enter a higher number: " (( low high )) || print -u2 "No, ${high} is not higher than ${low}. Please re-enter." done print Low: ${low} print High: ${high}
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
|
Reply: (edit)...still no luck. Maybe this will do it: (if not, there should be a 'less-than' symbol between 'low' and 'high' in the two conditions): integer low high while ! (( low \< high )) do read low?"Enter a number: " read high?"Enter a higher number: " (( low \< high )) || print -u2 "No, ${high} is not higher than ${low}. Please re-enter." done print Low: ${low} print High: ${high}
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: