How to compare ASCII char with octal number

How to compare ASCII char with octal number

am 05.11.2007 09:57:34 von Peter

Hi,

In the function below i select a random ASCII character (A-Z) which
must be pressed by a user.
The ASCII character is generated by printing a character in octal
notation. I need to compare
the key pressed by the end-user with the character represented by the
octal number. Therefore
i convert the octal number to a character using the print
instruction ;

uorg=`print "\0${randoctkey}"`

Is there a better/nicer way to do this ?

warnandwait() {

print "\nTHINK! Incorrect use of this tool can stop all
communications."
typeset -i i=0
while ((i <= 2));
do
print -n ".";
(( i = i + 1));
sleep 1
done
# generate random octal number in decimal 65-90
randoctkey=`echo "obase=8;$((RANDOM%(90-65+1)+65))"| bc`
print "\nPress the \"\0${randoctkey}\" key to continue"

uresp=`getch`
uorg=`print "\0${randoctkey}"`

if [[ $uorg != $uresp ]]
then
print "If even pressing the right key is a challenge,"
print "consider NOT using this script."
exit 1
fi

Re: How to compare ASCII char with octal number

am 05.11.2007 10:30:12 von Cyrus Kriticos

Peter wrote:
> Hi,
>
> In the function below [...]

Which OS?

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.

Re: How to compare ASCII char with octal number

am 05.11.2007 11:25:47 von Peter

On 5 nov, 10:30, Cyrus Kriticos wrote:
> Peter wrote:
> > Hi,
>
> > In the function below [...]
>
> Which OS?
>
> --
> Best regards | Be nice to America or they'll bring democracy to
> Cyrus | your country.

AIX 5.2