Start New Discussion within our Software Development Community

Can someone tell me why this routine doesnt print out read/write statistics for the first device but does for the other two. I cant seem to work it out. Oh its a ksh script runnin on a solaris 10 box.

find_disks()
{
NETWORKDRIVE=/tmp
HOST=`/usr/bin/hostname`
integer k=1
integer i=`iostat -en | grep 'c[0-9]t[0-9]d[0-9]$' | awk '{print $5}' |\
sort -u | wc | awk '{print $1}'`
#first find the total number of disks in the system and put the value into i
while ((k <= $i));
do
  DEVICE=`iostat -en | grep 'c[0-9]t[0-9]d[0-9]$' | awk '{print $5}' | sed -n $k"p"`
  #get the device
  echo "$DEVICE $STATS" #debug
  STATS=`iostat -xnp | egrep "device|$DEVICE$" | awk '{print $3" "$4}' | tail -1l`
  #get the kb/r and kb/w for the device and put them into the variable
  #STATS then add the stats to a text file
  echo $STATS > $NETWORKDRIVE/$HOST/$DEVICE
  ((k = k + 1));
done
}

The ouput from running the routine is:
./disk_stat
c1t0d0
c0t0d0 3.8 0.7
c1t1d0 0.0 0.0

and in the files is the following:
==> /tmp/testbench5/c0t0d0 <==
0.0 0.0
==> /tmp/testbench5/c1t0d0 <==
3.7 0.7
==> /tmp/testbench5/c1t1d0 <==
0.0 0.0

solved! maybe if i put the debug line after the command which fills the variable it wld work!!

This question has already been answered. Start a new discussion instead.