As always, most of this is untested (or deliberately flawed) to make sure you have to figure it out for youself
Originally Posted by Nick_the_Greek
The -z you are using merely checks if the variable is empty (or zero), expr length $BLAH lets you figure out the length of the variable, and the cut command is the one that lets you strip them back to the appropriate sizes.
WEPKEY=`echo $WEPKEY | cut -c 1-26`
HEXSTRIPPED=`echo $WEPKEY | sed 's/[^0-9A-F]//g'`
if [ $HEXSTRIPPED -ne $WEPKEY ];
# key is ASCII
SHORTASCII=`echo $WEPKEY | cut -c 1-10`
# now we have $SHORTASCII and $WEPKEY, we need to check the length
# of SHORTASCII and compare it to the length of WEPKEY. If SHORT is equal
# to 10, and wepkey is not equal to 26, then we use short, else wepkey
# unless neither are the right size, then we bail out.
# bonus side effect: we fail through to a 10char ascii key, rather than a
# 15 character ascii key
SHORTLEN=`expr length $SHORTASCII`
# etc. Same applies to HEX
# key is HEX
Edit: And wahey he finally joins the ranks of Senior Members!