My script is not giving result for 2 or more arguments

Hi,

I am new to shell scripting and my below script is not giving result for 2 or more arguments. Can anyone help pls.

#!/bin/sh
sname=$(basename $(readlink -nf $0))
echo "This is $sname, running at $(date)"
echo "It is running on $(hostname)"
echo "Script being run by"
echo " User $(grep "^$USER:" /etc/passwd | cut -d: -f1)"
echo " UID $(grep "^$USER:" /etc/passwd | cut -d: -f3)"
echo " who is really $(grep "^$USER:" /etc/passwd | cut -d: -f5)"
echo ""
echo "Called with $# arguments"
for ((i=0 ; i < $# ; i++))
do
if test -f "$*"
then  
echo "-> Argument $* is a file"
ls -l $*
else
  echo "-> Argument $* either is not a regular file, or doesn't exist"
fi
done
array=($@);
for ((i=0 ; i < ${#array} ; i++))
do
        echo $i;
        echo ${array[$i]};
done

replace the echo with ur test code.

HTH,
PL

Doesn't work

---------- Post updated at 02:30 AM ---------- Previous update was at 02:17 AM ----------

I got the solution ....thanks...sharing with you guys

#!/bin/sh
sname=$(basename $(readlink -nf $0))
echo "This is $sname, running at $(date)"
echo "It is running on $(hostname)"
echo "Script being run by"
echo " User $(grep "^$USER:" /etc/passwd | cut -d: -f1)"
echo " UID $(grep "^$USER:" /etc/passwd | cut -d: -f3)"
echo " who is really $(grep "^$USER:" /etc/passwd | cut -d: -f5)"
echo ""
echo "Called with $# arguments"
array=("$@")
for ((i=0 ; i < $# ; i++))
do
if test -f "${array[$i]}"
then  
echo "-> Argument ${array[$i]} is a file"
ls -l ${array[$i]}
else
  echo "-> Argument ${array[$i]} either is not a regular file, or doesn't exist"
fi
done

Should be:

for ((i=0 ; i < ${#array} ; i++))