Fellow Sluggers, I am having a retarded moment with this program I am
writing. When ever I run it I get an error in the error log that I
cannot understand. The beginning of the script and part of the error
log are below. Can anyone see where I have gone wrong?
while [ $lc -le $nl ]
do
ppnum=$pnum # move phonenum to prev
phone num.
ppext=$pext # move extension to prev
ext.
read pnum pext other2
lc=`expr $lc + 1` # increment num recs read
# The following statement deals with an account number record following
a
# summed time record, and prints out the previous summed information.
****** The error pertains to this section here, and in particular this
this if statement.
if [[$pext - gt 299] - a [$ppext - lt 300] - a [$str -eq 1]] ;
then
echo $lc $ppnum
"${totaltime[0]}:${totaltime[1]}:${totaltime[2]}" $ppext $calls
totaltime[2]=$seconds;totaltime[1]=$minutes;totaltime[0]=$hours
calls=0
# The following statement prints out the previous summed information
when a time
# record w/ a different phone number that the previous summed time
record is encountered.
# It must be a prev summed time record and not just a time recored.
Time
# records associated with account records are not summed in this
program. and then
# the current record is summed.
elif [ $pnum -ne $ppnum -a $pext -lt 300 -a $str = 1 ] ; then
echo $lc $ppnum
"${totaltime[0]}:${totaltime[1]}:${totaltime[2]}" $ppext $calls
totaltime[2]=$seconds;totaltime[1]=$minutes;totaltime[0]=$hours
calls=0
newtime=(`echo "$other2" | awk -F : '{ print $1" "$2" "$3
}'`) # read line and parse variables.
newtime[2]=`echo "${newtime[2]}" | sed 's/^0//'` # strip
leading zeros
totaltime[2]=$(( ${totaltime[2]} + ${newtime[2]} )) # add
newtime[2] to totaltime[2]
if [[ ${totaltime[2]} -gt 59 ]] ; then
totaltime[1]=$(( ${totaltime[1]} + 1 ))
totaltime[2]=$(( ${totaltime[2]} - 60 ))
fi
newtime[1]=`echo "${newtime[1]}" | sed 's/^0//'` # strip
leading zeros
totaltime[1]=$(( ${totaltime[1]} + ${newtime[1]} )) # add
newtime[2] to totaltime[2]
if [[ ${totaltime[1]} -gt 59 ]] ; then
totaltime[0]=$(( ${totaltime[0]} + 1 ))
totaltime[1]=$(( ${totaltime[1]} - 60 ))
fi
newtime[0]=`echo "${newtime[0]}" | sed 's/^0//'` # strip
leading zeros
totaltime[0]=$(( ${totaltime[0]} + ${newtime[0]} ))
calls=`expr $calls + 1`
str=1
The error log looks like this:
++ ppnum=09585825
++ ppext=216
++ read pnum pext other2
+++ expr 8 + 1
++ lc=9
++ '[[1157151' - gt '299]' - a '[216' - lt '300]' - a '[1' -eq '1]]'
**** It should take this condition but it blows right past the
statement and on to the next conditional statement.
./read.comb2: [[1157151: command not found
++ '[' 1042814000 -ne 09585825 -a 1157151 -lt 300 -a 1 = 1 ']'
++ '[' 1157151 -lt 300 -a 1 = 1 ']'
++ '[' 1042814000 -eq 09585825 -a 1157151 = 216 -a 1157151 -lt 300 ']'
++ str=0
++ '[' 9 -le 388501 ']'
++ ppnum=1042814000
++ ppext=1157151
++ read pnum pext other2
+++ expr 9 + 1
++ lc=10
++ '[[1452319' - gt '299]' - a '[1157151' - lt '300]' - a '[0' -eq '1]]'
./read.comb2: [[1452319: command not found
++ '[' 1120096612 -ne 1042814000 -a 1452319 -lt 300 -a 0 = 1 ']'
++ '[' 1452319 -lt 300 -a 1 = 1 ']'
++ '[' 1120096612 -eq 1042814000 -a 1452319 = 1157151 -a 1452319 -lt 300
']'
++ s
In addition it is blowing right past the if statement as if it did not
exist, and it should be taking it based on the results of each
conditional statement.
Does anyone have a better eye than I do for this problem?
Michael C Rock
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:20:38 EDT