From: nic Date: Tue, 21 Jun 2005 17:41:09 +0000 (+0000) Subject: move awk script into bash, as strtonum() is broken on some systems X-Git-Tag: v1_7_100~1165 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=b35c862e781d219adaf4e51be15ff5a4f3f5acdc move awk script into bash, as strtonum() is broken on some systems add a bit more help when we hit errors too --- diff --git a/lustre-iokit/obdfilter-survey/obdfilter-survey b/lustre-iokit/obdfilter-survey/obdfilter-survey index 6a76292..b11f898 100755 --- a/lustre-iokit/obdfilter-survey/obdfilter-survey +++ b/lustre-iokit/obdfilter-survey/obdfilter-survey @@ -195,17 +195,40 @@ create_objects () { local nobj=$3 local rfile=$4 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1 - n=(`awk < $rfile \ - '/is object id/ {obj=strtonum($6);\ - first=!not_first; not_first=1;\ - if (first) first_obj=obj; - else if (obj != prev + 1) exit;\ - prev=obj; n++}\ - END {printf "%d %d\n", first_obj, n}'`) - if ((n[1] != nobj)); then - echo "ERROR" - else - echo ${n[0]} + first=0 + prev=0 + count=0 + error=0 + while read line; do + echo "$line" | grep -q 'is object id' + if [ $? -ne 0 ]; then + continue + fi + if [ $first -eq 0 ]; then + first=$(echo $line | awk '{print $6}') + first=$(printf "%d" $first) + prev=$first + count=1 + else + obj=$(echo $line | awk '{print $6}') + obj=$(printf "%d" $obj) + diff=$((obj - (prev+1))) + if [ $diff -ne 0 ]; then + error=1 + fi + prev=$obj + count=$((count+1)) + fi + done < $rfile + if [ $nobj -ne $count ]; then + echo "ERROR: $nobj != $count" >&2 + cat $rfile >&2 + echo "ERROR" + elif [ $error -ne 0 ]; then + echo "ERROR: non contiguous objs found" >&2 + echo "ERROR" + else + echo $first fi }