There is no need to set it in an array. You can use the substring operator to get each individual character. It works like ${variablename:offset:length} so use 1 for length and give it a value of 0 through length for offset.
This also avoids needing to split on spaces, which allows people to put spaces, wildcards, and other special characters in their passwords without this choking.
Thanks for your quick response but its not working on my system. I'm on AIX 7.1
ce9888@a03d:/users/ce9888 > N=2
ce9888@a03d:/users/ce9888 > pass="12345"
ce9888@a03d:/users/ce9888 > echo "${pass:$N:1}"
ksh: "${pass:$N:1}": 0403-011 The specified substitution is not valid for this command.
ce9888@a03d:/users/ce9888 >
In AIX (every AIX since 3.2 - the one i started with at the beginning of the nineties) the default login shell is a ksh88 version f. Fortunately there is a ksh93 installed per default (in every AIX since 4.something, ~2000), you just have to start it:
/usr/bin/ksh93
contains a ksh93 version t on AIX.
@Corona:
even ksh88 understands POSIX process substitution (" $(....) ")and can do variable manipulation:
x="ab*de"
while [ -n "$x" ] ; do
first="${x%${x#?}}"
x="${x#?}"
print - "First: $first \tRest of x: $x"
done