How to compare ASCII char with octal number

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
Peter [ Mo, 05 November 2007 09:57 ] [ ID #1862382 ]

Re: How to compare ASCII char with octal number

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

Which OS?

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
Cyrus Kriticos [ Mo, 05 November 2007 10:30 ] [ ID #1862384 ]

Re: How to compare ASCII char with octal number

On 5 nov, 10:30, Cyrus Kriticos <cyrus.kriti... [at] googlemail.com> 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
Peter [ Mo, 05 November 2007 11:25 ] [ ID #1862385 ]
Linux » comp.unix.shell » How to compare ASCII char with octal number

Vorheriges Thema: How to know if the terminal supports GUI
Nächstes Thema: IRIX - ksh use of set -x