integer comparasion troubles.

Hi, I am trying to store the real name of currently logged in users as a variable or in an array. I have been having troubly with this, below I have it set into a variable. But when it enters the loop to assign each to a variable it says:
Integer expression expected.

##!/bin/bash
## userprocesses
#Display actual users name

who | wc -l > nousers
set -- cut -f1 nousers
numberusers=$1
usercnt=1 \# counter used in setup
pos=1 \# position in array
outcount=1 \# counter used in getname method
userout=1 \# set for output 

	who -q > tempA
	set -- $\( cut -f "$pos" tempA\); 

while [ "$usercnt" -le "$numberusers" ]
do
eval user${pos}=$1
shift
usercnt='expr usercnt + 1'
pos='expr pos + 1'

done

echo "$user1 $user2 $user3"

Line 2 sets $1 to "cut"
Line 3 sets $numberusers to $1, ie. "cut"
While loop fails on first iteration since "cut" is not an integer.

Try using set -x to debug your scripts.

numberusers=$( who | wc -l )

You don't need expr in bash; expr is an external command (i.e., it's slow), and bash (like all POSIX shells) has integer arithmetic built in:

usercnt=$(( $usercnt + 1 ))
pos=$(( $pos + 1 ))

If you do use expr, you need to give it the contents of the variables, not their names (e.g., $usercnt, not usercnt).

The whole operation can be done much more efficiently by reading the output of who directly:

who | while read name junk
do
   : do whatever
done

If you want to put the names into an array, use bash's built-in arrays:

names=( who | cut -d ' ' -f1 )
: