GCTEII
1
I am making a script to check the parameters, but it seems that I can't catch the parameters by loop.
[tester@test0102d test]$ cat sendmsg.sh
#!/bin/sh
## Parameter Check
i=0
max=$#
while [ $i -lt $max ]
do
PARAM[${i}]=$${i}
i=`expr ${i} + 1`
echo ${PARAM[${i}]}
done
How can I get the $1, $2, $3 by loop and set their values to PARAM[${i}]?
Thank u in advance.
Try.
count=1
for i in $@
do
PARAM[${count}]=${i}
(( count += 1 ))
done
Cheers.
GCTEII
3
Thank u in advance!
Test OK !
[tester@test0102d test]$ cat sendmsg.sh
#!/bin/sh
## Parameter Check
cnt=0
for i in $@
do
PARAM[${cnt}]=${i}
echo ${PARAM[${cnt}]}
cnt=`expr ${cnt} + 1`
done
[tester@test0102d test]$ sh sendmsg.sh test test1 test2
test
test1
test2