LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-10-2014, 01:23 AM   #61
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled

have a query..but let me check the details ..then will take your help..

Thanks in advance

Last edited by santosh0782; 01-10-2014 at 01:51 AM.
 
Old 01-11-2014, 07:10 AM   #62
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Hi Friend,

I am working on a new script, and getting this error:

Error:

./thrshld_rms.sh

./thrshld_rms.sh: line 105: unexpected token `newline', conditional binary operator expected

./thrshld_rms.sh: line 105: syntax error near `\'

./thrshld_rms.sh: line 105: ` "${val[1]}" -ge 5 && "${val[1]}" -lt 10 || \ '
=====================================

could you please help me to get this error resolved, and if there are any suggestions to make this script more human readable then please advise. Thanks a lot in advance :-)

script:

Sample 3 input files(Here as of now we are not sure, how the AverageAnswerDelay's data format would be, for now we got the screenshot of this dashboard where the AverageAnswerDelays time is shown in this format HH:MM:SS, considering the same i have written a script, but if it is only in seconds then will change it later, once i get the access to database then will check ,if it is coming in digits only like 30 sec or etc..or the format is same in HH:MM:SS)

also, in the script i used the threshold for all the fields(AverageAnswerDelay ie. AAD,AverageSpeedOfAnswer ie.ASA,CallsWaiting i.e Cwait,CallsAnswered ie.ACD,CallsAbandoned ie. Cabnd) if it crosses that then their color will get change.

Opt1.txt:

"AverageAnswerDelay"||','||"AverageSpeedOfAnswer"||','||"CallsWaiting"||','||"CallsAnswered"||','||" CallsAbandoned"

------------------------------------------------------------------------------------------------------------------

00:00:31,00:00:32,3,2,1

Opt2.txt:

"AverageAnswerDelay"||','||"AverageSpeedOfAnswer"||','||"CallsWaiting"||','||"CallsAnswered"||','||" CallsAbandoned"

------------------------------------------------------------------------------------------------------------------

00:00:34,00:00:03,9,3,1

Opt3.txt:

"AverageAnswerDelay"||','||"AverageSpeedOfAnswer"||','||"CallsWaiting"||','||"CallsAnswered"||','||" CallsAbandoned"

------------------------------------------------------------------------------------------------------------------

00:01:06,00:00:07,3,2,1


Code:
#-----------------------------------------------------------------#

#!/bin/ksh

#-----------------------------------------------------------------#

dataDir="/home/www/BCARD/data/rms/"

scriptDir="/home/www/BCARD/scripts/rms/"

Pge_Update_dt="/home/www/BCARD/custom/CEMV/RMS/"

#-----------------------------------------------------------------#

#. /wload/111t/app/oracle/oe/bin/oracle_login

 

#for i in opt1 opt2 opt3

#do

#sqlplus CEMVOWNER/c3mv0wner#@Dacon @$i.sql

#done

 

#opt1_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt1_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]')              #MaxWaitTime (AverageAnswerDelay)

#opt1_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt1_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]')              #AverageAnswerDelay (AverageSpeedOfAnswer)

opt1_Cwait=$(awk -F ',' '{ print $3 }' ${scriptDir}/opt1.txt|grep '^[0-9]')             #CallsWaiting (CallsWaiting)

opt1_ACD=$(awk -F ',' '{ print $4 }' ${scriptDir}/opt1.txt|grep '^[0-9]')               #CallsAnswered (ACDCalls)

opt1_Cabnd=$(awk -F ',' '{ print $5 }' ${scriptDir}/opt1.txt|grep '^[0-9]')             #CallsAbandoned (AbandonedCalls)

 

#opt2_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt2_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt2.txt|grep '^[0-9]')              #MaxWaitTime (AverageAnswerDelay)
#opt2_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt2_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt2.txt|grep '^[0-9]')              #AverageAnswerDelay (AverageSpeedOfAnswer)

opt2_Cwait=$(awk -F ',' '{ print $3 }' ${scriptDir}/opt2.txt|grep '^[0-9]')             #CallsWaiting (CallsWaiting)

opt2_ACD=$(awk -F ',' '{ print $4 }' ${scriptDir}/opt2.txt|grep '^[0-9]')               #CallsAnswered (ACDCalls)

opt2_Cabnd=$(awk -F ',' '{ print $5 }' ${scriptDir}/opt2.txt|grep '^[0-9]')             #CallsAbandoned (AbandonedCalls)

 
#opt3_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt3_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt3.txt|grep '^[0-9]')              #MaxWaitTime (AverageAnswerDelay)
#opt3_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt3_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt3.txt|grep '^[0-9]')              #AverageAnswerDelay (AverageSpeedOfAnswer)

opt3_Cwait=$(awk -F ',' '{ print $3 }' ${scriptDir}/opt3.txt|grep '^[0-9]')             #CallsWaiting (CallsWaiting)

opt3_ACD=$(awk -F ',' '{ print $4 }' ${scriptDir}/opt3.txt|grep '^[0-9]')               #CallsAnswered (ACDCalls)

opt3_Cabnd=$(awk -F ',' '{ print $5 }' ${scriptDir}/opt3.txt|grep '^[0-9]')             #CallsAbandoned (AbandonedCalls)

 

#-----------------------------------------------------------------#

#Defining Variables for lables and their values

#-----------------------------------------------------------------#

val[1]=${opt1_AAD}

val[2]=${opt2_AAD}

val[3]=${opt3_AAD}

val[4]=${opt1_ASA}

val[5]=${opt2_ASA}

val[6]=${opt3_ASA}

 

 

val[7]=${opt1_Cwait}

val[8]=${opt2_Cwait}

val[9]=${opt3_Cwait}

val[10]=${opt1_ACD}

val[11]=${opt2_ACD}

val[12]=${opt3_ACD}

val[13]=${opt1_Cabnd}

val[14]=${opt2_Cabnd}

val[15]=${opt3_Cabnd}

 

lbl[1]='Opt 1 Sched : MaxWaitTime'

lbl[2]='Opt 2 Operations : MaxWaitTime'

lbl[3]='Option 3 : MaxWaitTime'

lbl[4]='Opt 1 Sched : AverageAnswerDelay'

lbl[5]='Opt 2 Operations : AverageAnswerDelay'

lbl[6]='Option 3 : AverageAnswerDelay'

 

 

lbl[7]='Opt 1 Sched : CallsWaiting'

lbl[8]='Opt 2 Operations : CallsWaiting'

lbl[9]='Option 3 : CallsWaiting'

lbl[10]='Opt 1 Sched : CallsAnswered'

lbl[11]='Opt 2 Operations : CallsAnswered'

lbl[12]='Option 3 : CallsAnswered'

lbl[13]='Opt 1 Sched : CallsAbandoned'

lbl[14]='Opt 2 Operations : CallsAbandoned'

lbl[15]='Option 3 : CallsAbandoned'

#-----------------------------------------------------------------#

 

#Drawing Pad

#-----------------------------------------------------------------#

#Reflecting data in 15 xmls for(MaxWaitTime/AverageAnswerDelay,AverageAnswerDelay/AverageSpeedOfAnswer,CallsWaiting,CallsAnswered/ACDCalls and CallsAbandoned/AbandonedCalls)

#-----------------------------------------------------------------#

 

for i in $(seq 1 1 15)

do

echo "<chart manageResize='1' bgAlpha='50' pallette='1' bgColor='FFFFFF' bgAlpha='45' bgRatio='50,45' bgAngle='90'>" >>${dataDir}/dp_${i}a.TMP.xml

echo "<annotations scaleText='1'>" >>${dataDir}/dp_${i}a.TMP.xml

echo "        <annotationGroup id='Grp1'>" >>${dataDir}/dp_${i}a.TMP.xml

        if [[ $i -le 6 && \

                "${val[1]}" -lt 5 || \

                "${val[2]}" -lt 5 || \

                "${val[3]}" -lt 5 || \

                "${val[4]}" -lt 30 || \

                "${val[5]}" -lt 30 || \

                "${val[6]}" -lt 30 ]]

        then

	echo "GREEN"


echo "                <annotation type='text' x='175' y='50' fontSize='80' bold='1' label='${val[$i]}' color='00FF00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

echo "                <annotation type='text' x='175' y='110' fontSize='17' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

        elif [[ $i -le 6 && \

                "${val[1]}" -ge 5 && "${val[1]}" -lt 10 || \

                "${val[2]}" -ge 5 && "${val[2]}" -lt 10 || \

                "${val[3]}" -ge 5 && "${val[3]}" -lt 10 || \

                "${val[4]}" -ge 30 && "${val[4]}" -lt 60 || \

                "${val[5]}" -ge 30 && "${val[5]}" -lt 60 || \

                "${val[6]}" -ge 30 && "${val[6]}" -lt 60 ]]

        Then
	echo "AMBER"

echo "                <annotation type='text' x='175' y='50' fontSize='80' bold='1' label='${val[$i]}' color='FF7E00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

echo "                <annotation type='text' x='175' y='110' fontSize='17' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

 

        elif [[ $i -le 6 && \

                "${val[1]}" -ge 11 || \

                "${val[2]}" -ge 11 || \

                "${val[3]}" -ge 11 || \

                "${val[4]}" -ge 60 || \

                "${val[5]}" -ge 60 || \

                "${val[6]}" -ge 60 ]]

        then
	echo "RED"

echo "                <annotation type='text' x='175' y='50' fontSize='80' bold='1' label='${val[$i]}' color='FF0000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

echo "                <annotation type='text' x='175' y='110' fontSize='17' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

        fi

 

        if [[ $i -gt 6 && \

                "${val[7]}" -lt 1 || \

                "${val[8]}" -lt 1 || \

                "${val[9]}" -lt 1 || \

                "${val[10]}" -eq "${opt1_ACD}" || \

                "${val[11]}" -eq "${opt2_ACD}" || \

                "${val[12]}" -eq "${opt3_ACD}" || \

                "${val[13]}" -lt 10 || \

                "${val[14]}" -lt 10 || \

                "${val[15]}" -lt 10 ]]

        then
		echo "GREEN"

echo "                <annotation type='text' x='175' y='50' fontSize='100' bold='1' label='${val[$i]}' color='00FF00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

echo "                <annotation type='text' x='175' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

 

        elif [[ $i -gt 6 && \

                "${val[7]}" -lt 2 || \

                "${val[8]}" -lt 2 || \

                "${val[9]}" -lt 2 || \

                "${val[13]}" -lt 20 || \

                "${val[14]}" -lt 20 || \

                "${val[15]}" -lt 20 ]]

then
		echo "AMBER"

echo "                <annotation type='text' x='175' y='50' fontSize='100' bold='1' label='${val[$i]}' color='FF7E00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

echo "                <annotation type='text' x='175' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

        elif [[ $i -gt 6 && \

                "${val[7]}" -gt 5 || \

                "${val[8]}" -gt 5 || \

                "${val[9]}" -gt 5 || \

                "${val[13]}" -lt 21 || \

                "${val[14]}" -lt 21 || \

                "${val[15]}" -lt 21 ]]

        then
		echo "RED"

echo "                <annotation type='text' x='175' y='50' fontSize='100' bold='1' label='${val[$i]}' color='FF0000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

echo "                <annotation type='text' x='175' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

 

        fi

 

 

echo "        </annotationGroup>" >>${dataDir}/dp_${i}a.TMP.xml

echo "</annotations>" >>${dataDir}/dp_${i}a.TMP.xml

echo "<styles>" >>${dataDir}/dp_${i}a.TMP.xml

echo "        <definition>" >>${dataDir}/dp_${i}a.TMP.xml

echo "                <style name='myBevel' type='Bevel' />" >>${dataDir}/dp_${i}a.TMP.xml

echo "        </definition>" >>${dataDir}/dp_${i}a.TMP.xml

echo "        <application>" >>${dataDir}/dp_${i}a.TMP.xml

echo "                <apply toObject='Background' styles='myBevel' />" >>${dataDir}/dp_${i}a.TMP.xml

echo "        </application>" >>${dataDir}/dp_${i}a.TMP.xml

echo "</styles>" >>${dataDir}/dp_${i}a.TMP.xml

echo "</chart>" >>${dataDir}/dp_${i}a.TMP.xml

 

done

 

#-----------------------------------------------------------------#

#To Populate Today's date and Time

#-----------------------------------------------------------------#

last_date=$(date)

echo '<?xml version="1.0"?>'>${Pge_Update_dt}/LastUpdatedDate.xml

echo "<root>">>${Pge_Update_dt}/LastUpdatedDate.xml

echo "<date>">>${Pge_Update_dt}/LastUpdatedDate.xml

echo "<LastUpdatedDt>$last_date</LastUpdatedDt>">>${Pge_Update_dt}/LastUpdatedDate.xml

echo "</date>">>${Pge_Update_dt}/LastUpdatedDate.xml

echo "</root>">>${Pge_Update_dt}/LastUpdatedDate.xml

#-----------------------------------------------------------------#

Last edited by santosh0782; 01-11-2014 at 07:46 AM.
 
Old 01-11-2014, 08:00 AM   #63
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
This might be a simple typo:
Code:
        elif [[ $i -le 6 && \
                "${val[1]}" -ge 5 && "${val[1]}" -lt 10 || \
                "${val[2]}" -ge 5 && "${val[2]}" -lt 10 || \
                "${val[3]}" -ge 5 && "${val[3]}" -lt 10 || \
                "${val[4]}" -ge 30 && "${val[4]}" -lt 60 || \
                "${val[5]}" -ge 30 && "${val[5]}" -lt 60 || \
                "${val[6]}" -ge 30 && "${val[6]}" -lt 60 ]]
        Then # that should be then, not Then
    echo "AMBER"
Also: The first line of the script must be the she-bang. Remove the the lines in front of it.
 
1 members found this post helpful.
Old 01-11-2014, 08:19 AM   #64
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
ok, Thanks a lot :-)

one more thing, actually i am awwy from my workdesk, and i have taken this code in an e-mail, now on my laptop i have linux in Virtual Box, do you know any way to copy this code from my e-mail to Linux in Virtual Box, so that i can copy all this code to linux and try running this script here only.

i was trying to copy code and paste but its not working.. is there any way?
 
Old 01-11-2014, 08:36 AM   #65
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
I'm not sure I can help with this one, I hardly ever use Windows (haven't used windows at home since 1997) and I'm not familiar with Virtual Box.

If Virtual box does not have the capability to copy-paste to from Windows I would save the attachment (or copy/paste to a new text file if the script is part of the e-mail body) and scp it to the VM (using winScp).

Do make sure that the file in the VM is a Linux text file and not a Windows one (different EOL). You can use the dos2unix command to convert if needed.
 
1 members found this post helpful.
Old 01-11-2014, 08:52 AM   #66
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
ok, No Problem..

Really appreciated your help.

Thanks a lot once again :-)
 
Old 01-12-2014, 12:10 AM   #67
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Hi,
Can we convert time into seconds and seconds into to time again.

for e.g. 00:01:03 want to convert this time to seconds only
and 258 seconds i want to convert it into the HH:MM:SS format, can we do that?
 
Old 01-12-2014, 03:38 AM   #68
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Quote:
Originally Posted by santosh0782 View Post
Hi,
Can we convert time into seconds and seconds into to time again.

for e.g. 00:01:03 want to convert this time to seconds only
and 258 seconds i want to convert it into the HH:MM:SS format, can we do that?
Are you looking for something like this:
Code:
#!/bin/bash

# time to seconds
TIME="0:4:18"

TS=( ${TIME//:/ } )
time2sec=$(( ${TS[0]}*3600 + ${TS[1]}*60 + ${TS[2]} ))

echo "$TIME -> $time2sec"

# seconds to time
SECONDS="258"

((h=${SECONDS}/3600))
((m=(${SECONDS}%3600)/60))
((s=${SECONDS}%60))
sec2time="$h:$m:$s"                              # without a possible leading zero
#sec2time=$(printf "%02d:%02d:%02d\n" $h $m $s)  # with a possible leading zero

echo "$SECONDS    -> $sec2time"

exit 0
This would be the result:
Code:
0:4:18 -> 258
258    -> 0:4:18
or, when needing the possible leading zero:
Code:
0:4:18 -> 258
258    -> 00:04:18

Last edited by druuna; 01-12-2014 at 03:42 AM. Reason: Added leading zero possibility
 
1 members found this post helpful.
Old 01-12-2014, 10:45 PM   #69
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Thanks a lot Friend :-) , i was looking out for the same. :-)
 
Old 01-12-2014, 10:48 PM   #70
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Hi Friend,

as i am working on new script, and i am unable to find out where is the error its giving me. could you please help me with the below code to find out the error and remove it.

Error message:
./thrshld_rms.sh: line 77: syntax error at line 104: `newline' unexpected

Code:
#!/bin/ksh
dataDir="/home/www/BCARD/data/rms/"
scriptDir="/home/www/BCARD/scripts/rms/"
#RMS_xml="/home/www/BCARD/data/rms/"
#RMS_TMP_xml="/home/www/BCARD/data/rms/"
Pge_Update_dt="/home/www/BCARD/custom/CEMV/RMS/"
#-----------------------------------------------------------------#
#. /wload/111t/app/oracle/oe/bin/oracle_login

#for i in opt1 opt2 opt3
#do
#sqlplus CEMVOWNER/c3mv0wner#@Dacon @$i.sql
#done

opt1_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]')                                               #MaxWaitTime (AverageAnswerDelay)
#opt1_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt1_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]')                                               #AverageAnswerDelay (AverageSpeedOfAnswer)
#opt1_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt1_Cwait=$(awk -F ',' '{ print $3 }' ${scriptDir}/opt1.txt|grep '^[0-9]')                                             #CallsWaiting (CallsWaiting)
opt1_ACD=$(awk -F ',' '{ print $4 }' ${scriptDir}/opt1.txt|grep '^[0-9]')                                               #CallsAnswered (ACDCalls)
opt1_Cabnd=$(awk -F ',' '{ print $5 }' ${scriptDir}/opt1.txt|grep '^[0-9]')                                             #CallsAbandoned (AbandonedCalls)

opt2_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt2.txt|grep '^[0-9]')                                               #MaxWaitTime (AverageAnswerDelay)
#opt2_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt2_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt2.txt|grep '^[0-9]')                                               #AverageAnswerDelay (AverageSpeedOfAnswer)
#opt2_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt2_Cwait=$(awk -F ',' '{ print $3 }' ${scriptDir}/opt2.txt|grep '^[0-9]')                                             #CallsWaiting (CallsWaiting)
opt2_ACD=$(awk -F ',' '{ print $4 }' ${scriptDir}/opt2.txt|grep '^[0-9]')                                               #CallsAnswered (ACDCalls)
opt2_Cabnd=$(awk -F ',' '{ print $5 }' ${scriptDir}/opt2.txt|grep '^[0-9]')                                             #CallsAbandoned (AbandonedCalls)

opt3_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt3.txt|grep '^[0-9]')                                               #MaxWaitTime (AverageAnswerDelay)
#opt3_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt3_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt3.txt|grep '^[0-9]')                                               #AverageAnswerDelay (AverageSpeedOfAnswer)
#opt3_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt3_Cwait=$(awk -F ',' '{ print $3 }' ${scriptDir}/opt3.txt|grep '^[0-9]')                                             #CallsWaiting (CallsWaiting)
opt3_ACD=$(awk -F ',' '{ print $4 }' ${scriptDir}/opt3.txt|grep '^[0-9]')                                               #CallsAnswered (ACDCalls)
opt3_Cabnd=$(awk -F ',' '{ print $5 }' ${scriptDir}/opt3.txt|grep '^[0-9]')                                             #CallsAbandoned (AbandonedCalls)

#-----------------------------------------------------------------#
#Defining Variables for lables and their values
#-----------------------------------------------------------------#
val[1]=${opt1_AAD}
val[2]=${opt2_AAD}
val[3]=${opt3_AAD}
val[4]=${opt1_ASA}
val[5]=${opt2_ASA}
val[6]=${opt3_ASA}


val[7]=${opt1_Cwait}
val[8]=${opt2_Cwait}
val[9]=${opt3_Cwait}
val[10]=${opt1_ACD}
val[11]=${opt2_ACD}
val[12]=${opt3_ACD}
val[13]=${opt1_Cabnd}
val[14]=${opt2_Cabnd}
val[15]=${opt3_Cabnd}

lbl[1]='Opt 1 Sched : MaxWaitTime'
lbl[2]='Opt 2 Operations : MaxWaitTime'
lbl[3]='Option 3 : MaxWaitTime'
lbl[4]='Opt 1 Sched : AverageAnswerDelay'
lbl[5]='Opt 2 Operations : AverageAnswerDelay'
lbl[6]='Option 3 : AverageAnswerDelay'


lbl[7]='Opt 1 Sched : CallsWaiting'
lbl[8]='Opt 2 Operations : CallsWaiting'
lbl[9]='Option 3 : CallsWaiting'
lbl[10]='Opt 1 Sched : CallsAnswered'
lbl[11]='Opt 2 Operations : CallsAnswered'
lbl[12]='Option 3 : CallsAnswered'
lbl[13]='Opt 1 Sched : CallsAbandoned'
lbl[14]='Opt 2 Operations : CallsAbandoned'
lbl[15]='Option 3 : CallsAbandoned'

#-----------------------------------------------------------------#

#Drawing Pad
#-----------------------------------------------------------------#
#Reflecting data in 15 xmls for(MaxWaitTime/AverageAnswerDelay,AverageAnswerDelay/AverageSpeedOfAnswer,CallsWaiting,CallsAnswered/ACDCalls and CallsAbandoned/AbandonedCalls)
#-----------------------------------------------------------------#
for i in $(seq 1 1 15)
do
echo "<chart manageResize='1' bgAlpha='50' pallette='1' bgColor='FFFFFF' bgAlpha='45' bgRatio='50,45' bgAngle='90'>" >>${dataDir}/dp_${i}a.TMP.xml
echo "<annotations scaleText='1'>" >>${dataDir}/dp_${i}a.TMP.xml
echo "        <annotationGroup id='Grp1'>" >>${dataDir}/dp_${i}a.TMP.xml
        if [[ $i -le 6 && \
                "${val[1]}" -lt 5 || \
                "${val[2]}" -lt 5 || \
                "${val[3]}" -lt 5 || \
                "${val[4]}" -lt 30 || \
                "${val[5]}" -lt 30 || \
                "${val[6]}" -lt 30 ]]
        then

echo "                <annotation type='text' x='175' y='50' fontSize='80' bold='1' label='${val[$i]}' color='00FF00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='175' y='110' fontSize='17' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
        elif [[ $i -le 6 && \
                "${val[1]}" -ge 5 && "${val[1]}" -lt 10 || \
                "${val[2]}" -ge 5 && "${val[2]}" -lt 10 || \
                "${val[3]}" -ge 5 && "${val[3]}" -lt 10 || \
                "${val[4]}" -ge 30 && "${val[4]}" -lt 60 || \
                "${val[5]}" -ge 30 && "${val[5]}" -lt 60 || \
                "${val[6]}" -ge 30 && "${val[6]}" -lt 60 ]]
        then

echo "                <annotation type='text' x='175' y='50' fontSize='80' bold='1' label='${val[$i]}' color='FF7E00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='175' y='110' fontSize='17' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

        elif [[ $i -le 6 && \
                "${val[1]}" -ge 11 || \
                "${val[2]}" -ge 11 || \
                "${val[3]}" -ge 11 || \
                "${val[4]}" -ge 60 || \
                "${val[5]}" -ge 60 || \
                "${val[6]}" -ge 60 ]]
        then
echo "                <annotation type='text' x='175' y='50' fontSize='80' bold='1' label='${val[$i]}' color='FF0000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='175' y='110' fontSize='17' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
        fi

        if [[ $i -gt 6 && \
                "${val[7]}" -lt 1 || \
                "${val[8]}" -lt 1 || \
                "${val[9]}" -lt 1 || \
                "${val[10]}" -eq "${opt1_ACD}" || \
                "${val[11]}" -eq "${opt2_ACD}" || \
                "${val[12]}" -eq "${opt3_ACD}" || \
                "${val[13]}" -lt 10 || \
                "${val[14]}" -lt 10 || \
                "${val[15]}" -lt 10 ]]
        then
echo "                <annotation type='text' x='175' y='50' fontSize='100' bold='1' label='${val[$i]}' color='00FF00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='175' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

        elif [[ $i -gt 6 && \
                "${val[7]}" -lt 2 || \
                "${val[8]}" -lt 2 || \
                "${val[9]}" -lt 2 || \
                "${val[13]}" -lt 20 || \
                "${val[14]}" -lt 20 || \
                "${val[15]}" -lt 20 ]]
        then
echo "                <annotation type='text' x='175' y='50' fontSize='100' bold='1' label='${val[$i]}' color='FF7E00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='175' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
        elif [[ $i -gt 6 && \
                "${val[7]}" -gt 5 || \
                "${val[8]}" -gt 5 || \
                "${val[9]}" -gt 5 || \
                "${val[13]}" -lt 21 || \
                "${val[14]}" -lt 21 || \
                "${val[15]}" -lt 21 ]]
        then
echo "                <annotation type='text' x='175' y='50' fontSize='100' bold='1' label='${val[$i]}' color='FF0000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='175' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

        fi


echo "        </annotationGroup>" >>${dataDir}/dp_${i}a.TMP.xml
echo "</annotations>" >>${dataDir}/dp_${i}a.TMP.xml
echo "<styles>" >>${dataDir}/dp_${i}a.TMP.xml
echo "        <definition>" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <style name='myBevel' type='Bevel' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "        </definition>" >>${dataDir}/dp_${i}a.TMP.xml
echo "        <application>" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <apply toObject='Background' styles='myBevel' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "        </application>" >>${dataDir}/dp_${i}a.TMP.xml
echo "</styles>" >>${dataDir}/dp_${i}a.TMP.xml
echo "</chart>" >>${dataDir}/dp_${i}a.TMP.xml

done

#-----------------------------------------------------------------#
#To Populate Today's date and Time
#-----------------------------------------------------------------#
last_date=$(date)
echo '<?xml version="1.0"?>'>${Pge_Update_dt}/LastUpdatedDate.xml
echo "<root>">>${Pge_Update_dt}/LastUpdatedDate.xml
echo "<date>">>${Pge_Update_dt}/LastUpdatedDate.xml
echo "<LastUpdatedDt>$last_date</LastUpdatedDt>">>${Pge_Update_dt}/LastUpdatedDate.xml
echo "</date>">>${Pge_Update_dt}/LastUpdatedDate.xml
echo "</root>">>${Pge_Update_dt}/LastUpdatedDate.xml
#-----------------------------------------------------------------#
 
Old 01-13-2014, 04:22 AM   #71
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Do you get that error message with the script you posted or one that might be different? I'm asking because the lines mentioned in the error message point to an empty line (line 77) and to a seemingly random val[X] entry (line 104).

At first glance and without knowing what this code is supposed to do I only see one thing that might have caused the error: One or more val[X] array entries do not have the content you expect it to be.

- First thing you should do is to put double quotes around the assignments:
Code:
val[1]="${opt1_AAD}"
val[2]="${opt2_AAD}"
val[3]="${opt3_AAD}"
etc
- Second thing: Check the content of the val[X] entries to see if they are what is expected (which could be a typo or unforseen entry in your input file). Insert this piece of code after lbl[15]='Option 3 : CallsAbandoned' and before #Drawing Pad:
Code:
for X in $(seq 1 15)
do
  echo "val[$X] : ${val[$X]}"
  echo "lbl[$X] : ${lbl[$X]}"
done

exit 0
This will show the content of the val and lbl array's (and exit when that is done).
 
1 members found this post helpful.
Old 01-13-2014, 04:41 AM   #72
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Thanks a ton Friend :-)

I written the code below way now, and it working fine.
Code:
#!/bin/ksh
dataDir="/home/www/BCARD/data/rms/"
scriptDir="/home/www/BCARD/scripts/rms/"
#RMS_xml="/home/www/BCARD/data/rms/"
#RMS_TMP_xml="/home/www/BCARD/data/rms/"
Pge_Update_dt="/home/www/BCARD/custom/CEMV/RMS/"
#-----------------------------------------------------------------#
#. /wload/111t/app/oracle/oe/bin/oracle_login

#for i in opt1 opt2 opt3
#do
#sqlplus CEMVOWNER/c3mv0wner#@Dacon @$i.sql
#done

opt1_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]')                                               #MaxWaitTime (AverageAnswerDelay)
#opt1_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt1_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]')                                               #AverageAnswerDelay (AverageSpeedOfAnswer)
#opt1_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt1_Cwait=$(awk -F ',' '{ print $3 }' ${scriptDir}/opt1.txt|grep '^[0-9]')                                             #CallsWaiting (CallsWaiting)
opt1_ACD=$(awk -F ',' '{ print $4 }' ${scriptDir}/opt1.txt|grep '^[0-9]')                                               #CallsAnswered (ACDCalls)
opt1_Cabnd=$(awk -F ',' '{ print $5 }' ${scriptDir}/opt1.txt|grep '^[0-9]')                                             #CallsAbandoned (AbandonedCalls)

opt2_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt2.txt|grep '^[0-9]')                                               #MaxWaitTime (AverageAnswerDelay)
#opt2_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt2_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt2.txt|grep '^[0-9]')                                               #AverageAnswerDelay (AverageSpeedOfAnswer)
#opt2_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt2_Cwait=$(awk -F ',' '{ print $3 }' ${scriptDir}/opt2.txt|grep '^[0-9]')                                             #CallsWaiting (CallsWaiting)
opt2_ACD=$(awk -F ',' '{ print $4 }' ${scriptDir}/opt2.txt|grep '^[0-9]')                                               #CallsAnswered (ACDCalls)
opt2_Cabnd=$(awk -F ',' '{ print $5 }' ${scriptDir}/opt2.txt|grep '^[0-9]')                                             #CallsAbandoned (AbandonedCalls)

opt3_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt3.txt|grep '^[0-9]')                                               #MaxWaitTime (AverageAnswerDelay)
#opt3_AAD=$(awk -F ',' '{ print $1 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt3_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt3.txt|grep '^[0-9]')                                               #AverageAnswerDelay (AverageSpeedOfAnswer)
#opt3_ASA=$(awk -F ',' '{ print $2 }' ${scriptDir}/opt1.txt|grep '^[0-9]'|awk -F ':' 'BEGIN{OFS=""} { print $1,$2,$3 }')
opt3_Cwait=$(awk -F ',' '{ print $3 }' ${scriptDir}/opt3.txt|grep '^[0-9]')                                             #CallsWaiting (CallsWaiting)
opt3_ACD=$(awk -F ',' '{ print $4 }' ${scriptDir}/opt3.txt|grep '^[0-9]')                                               #CallsAnswered (ACDCalls)
opt3_Cabnd=$(awk -F ',' '{ print $5 }' ${scriptDir}/opt3.txt|grep '^[0-9]')                                             #CallsAbandoned (AbandonedCalls)

#-----------------------------------------------------------------#
#Defining Variables for lables and their values
#-----------------------------------------------------------------#
val[1]="${opt1_AAD}"
val[2]="${opt2_AAD}"
val[3]="${opt3_AAD}"
val[4]="${opt1_ASA}"
val[5]="${opt2_ASA}"
val[6]="${opt3_ASA}"


val[7]="${opt1_Cwait}"
val[8]="${opt2_Cwait}"
val[9]="${opt3_Cwait}"
val[10]="${opt1_ACD}"
val[11]="${opt2_ACD}"
val[12]="${opt3_ACD}"
val[13]="${opt1_Cabnd}"
val[14]="${opt2_Cabnd}"
val[15]="${opt3_Cabnd}"

lbl[1]='Opt 1 Sched : MaxWaitTime'
lbl[2]='Opt 2 Operations : MaxWaitTime'
lbl[3]='Option 3 : MaxWaitTime'
lbl[4]='Opt 1 Sched : AverageAnswerDelay'
lbl[5]='Opt 2 Operations : AverageAnswerDelay'
lbl[6]='Option 3 : AverageAnswerDelay'


lbl[7]='Opt 1 Sched : CallsWaiting'
lbl[8]='Opt 2 Operations : CallsWaiting'
lbl[9]='Option 3 : CallsWaiting'
lbl[10]='Opt 1 Sched : CallsAnswered'
lbl[11]='Opt 2 Operations : CallsAnswered'
lbl[12]='Option 3 : CallsAnswered'
lbl[13]='Opt 1 Sched : CallsAbandoned'
lbl[14]='Opt 2 Operations : CallsAbandoned'
lbl[15]='Option 3 : CallsAbandoned'

#-----------------------------------------------------------------#
#Drawing Pad
#-----------------------------------------------------------------#
#Reflecting data in 15 xmls for(MaxWaitTime/AverageAnswerDelay,AverageAnswerDelay/AverageSpeedOfAnswer,CallsWaiting,CallsAnswered/ACDCalls and CallsAbandoned/AbandonedCalls)
#-----------------------------------------------------------------#
for i in $(seq 1 1 15)
do
echo "<chart manageResize='1' bgAlpha='50' pallette='1' bgColor='FFFFFF' bgAlpha='45' bgRatio='50,45' bgAngle='90'>" >>${dataDir}/dp_${i}a.TMP.xml
echo "<annotations scaleText='1'>" >${dataDir}/dp_${i}a.TMP.xml
echo "        <annotationGroup id='Grp1'>" >>${dataDir}/dp_${i}a.TMP.xml
        if [[ $i -le 3 ]]
        then
                        if [[ "${val[$i]}" -lt 5 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='85' bold='1' label='${val[$i]}' color='00FF00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

                        elif [[ "${val[$i]}" -ge 5 && "${val[$i]}" -le 10 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='85' bold='1' label='${val[$i]}' color='FF7E00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

                        elif [[ "${val[$i]}" -ge 11 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='85' bold='1' label='${val[$i]}' color='FF0000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
                        fi
        fi

        if [[ $i -gt 3 && $i -le 6 ]]
        then
                        if [[ "${val[$i]}" -le 30 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='85' bold='1' label='${val[$i]}' color='00FF00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

                        elif [[ "${val[$i]}" -gt 30 && "${val[$i]}" -le 60 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='85' bold='1' label='${val[$i]}' color='FF7E00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

                        elif [[ "${val[$i]}" -gt 60 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='85' bold='1' label='${val[$i]}' color='FF0000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
                        fi
        fi

        if [[ $i -gt 6 && $i -le 9 ]]
        then
                        if [[ "${val[$i]}" -lt 1 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='100' bold='1' label='${val[$i]}' color='00FF00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

                        elif [[ "${val[$i]}" -ge 1 && "${val[$i]}" -le 5 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='100' bold='1' label='${val[$i]}' color='FF7E00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

                        elif [[ "${val[$i]}" -gt 5 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='100' bold='1' label='${val[$i]}' color='FF0000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

                        fi
        fi
if [[ $i -gt 9 && $i -le 12 ]]
        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='100' bold='1' label='${val[$i]}' color='00FF00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

        fi

        if [[ $i -gt 12 && $i -le 15 ]]
        then
                        if [[ "${val[$i]}" -lt 10 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='100' bold='1' label='${val[$i]}' color='00FF00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

                        elif [[ "${val[$i]}" -ge 10 && "${val[$i]}" -le 20 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='100' bold='1' label='${val[$i]}' color='FF7E00' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

                        elif [[ "${val[$i]}" -gt 20 ]]
                        then
echo "                <annotation type='text' x='212.5' y='50' fontSize='100' bold='1' label='${val[$i]}' color='FF0000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <annotation type='text' x='212.5' y='110' fontSize='18' bold='1' label='${lbl[$i]}' color='000000' align='center' font='tohama,helvetica,arial,sans-serif' />" >>${dataDir}/dp_${i}a.TMP.xml

                        fi
        fi

echo "        </annotationGroup>" >>${dataDir}/dp_${i}a.TMP.xml
echo "</annotations>" >>${dataDir}/dp_${i}a.TMP.xml
echo "<styles>" >>${dataDir}/dp_${i}a.TMP.xml
echo "        <definition>" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <style name='myBevel' type='Bevel' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "        </definition>" >>${dataDir}/dp_${i}a.TMP.xml
echo "        <application>" >>${dataDir}/dp_${i}a.TMP.xml
echo "                <apply toObject='Background' styles='myBevel' />" >>${dataDir}/dp_${i}a.TMP.xml
echo "        </application>" >>${dataDir}/dp_${i}a.TMP.xml
echo "</styles>" >>${dataDir}/dp_${i}a.TMP.xml
echo "</chart>" >>${dataDir}/dp_${i}a.TMP.xml

done

#-----------------------------------------------------------------#
#To Populate Today's date and Time
#-----------------------------------------------------------------#
last_date=$(date)
echo '<?xml version="1.0"?>'>${Pge_Update_dt}/LastUpdatedDate.xml
echo "<root>">>${Pge_Update_dt}/LastUpdatedDate.xml
echo "<date>">>${Pge_Update_dt}/LastUpdatedDate.xml
echo "<LastUpdatedDt>$last_date</LastUpdatedDt>">>${Pge_Update_dt}/LastUpdatedDate.xml
echo "</date>">>${Pge_Update_dt}/LastUpdatedDate.xml
echo "</root>">>${Pge_Update_dt}/LastUpdatedDate.xml
#-----------------------------------------------------------------#
 
Old 01-13-2014, 06:00 AM   #73
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Hi Friend,

Code:
opt1_AAD=$(awk -F ',' '{ print $1 }' opt1.txt|grep '^[0-9]')
opt1_ASA=$(awk -F ',' '{ print $2 }' opt1.txt|grep '^[0-9]')
opt2_AAD=$(awk -F ',' '{ print $1 }' opt2.txt|grep '^[0-9]')
opt2_ASA=$(awk -F ',' '{ print $2 }' opt2.txt|grep '^[0-9]')
opt3_AAD=$(awk -F ',' '{ print $1 }' opt3.txt|grep '^[0-9]')
opt3_ASA=$(awk -F ',' '{ print $2 }' opt3.txt|grep '^[0-9]')

# time to seconds
for t in "${opt1_AAD}" "${opt1_ASA}" "${opt2_AAD}" "${opt2_ASA}" "${opt3_AAD}" "${opt3_ASA}"
do
TIME="${t}"

TS=( ${TIME//:/ } )
time2sec=$(( ${TS[0]}*3600 + ${TS[1]}*60 + ${TS[2]} ))

echo "$TIME -> $time2sec"

done
output:
00:01:12 -> 72
01:01:52 -> 3712
00:00:11 -> 11
00:00:05 -> 5
00:00:16 -> 16
00:00:07 -> 7

how could i get the output in the below format:
opt1_AAD=72
opt1_ASA=3712
opt2_AAD=11
opt2_ASA=5
opt3_AAD=16
opt3_ASA=7


so that i'll use these values to populate in the xmls by just putting ${opt1_AAD} ... etc
 
Old 01-13-2014, 07:10 AM   #74
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
I think the above approach is the hard way to accomplish this.

I assume that this:
Code:
opt1_AAD=$(awk -F ',' '{ print $1 }' opt1.txt|grep '^[0-9]')
fills opt1_AAD with a time (HH:MM:SS) from opt1.txt

I'm rather sure that the awk statement can be expanded to do all you want (get the time and convert it to seconds). However, I cannot provide you with an example 'cause I don't know what opt1.txt looks like.....

Here's a solution for doing it the hard way:
Code:
#!/bin/bash

opt1_AAD="00:01:12"
opt1_ASA="01:01:52"
opt2_AAD="00:00:11"
opt2_ASA="00:00:05"
opt3_AAD="00:00:16"
opt3_ASA="00:00:07"

opt1_AAD=$(X=( ${opt1_AAD//:/ }) ; echo "$((${X[0]}*3600+${X[1]}*60+${X[2]}))")
opt1_ASA=$(X=( ${opt1_ASA//:/ }) ; echo "$((${X[0]}*3600+${X[1]}*60+${X[2]}))")
opt2_AAD=$(X=( ${opt2_AAD//:/ }) ; echo "$((${X[0]}*3600+${X[1]}*60+${X[2]}))")
opt2_ASA=$(X=( ${opt2_ASA//:/ }) ; echo "$((${X[0]}*3600+${X[1]}*60+${X[2]}))")
opt3_AAD=$(X=( ${opt3_AAD//:/ }) ; echo "$((${X[0]}*3600+${X[1]}*60+${X[2]}))")
opt3_ASA=$(X=( ${opt3_ASA//:/ }) ; echo "$((${X[0]}*3600+${X[1]}*60+${X[2]}))")
You could use a loop to do this:
Code:
#!/bin/bash

opt1_AAD="00:01:12"
opt1_ASA="01:01:52"
opt2_AAD="00:00:11"
opt2_ASA="00:00:05"
opt3_AAD="00:00:16"
opt3_ASA="00:00:07"

for t in opt1_AAD opt1_ASA opt2_AAD opt2_ASA opt3_AAD opt3_ASA
do
  X=( ${!t//:/ } )
  eval ${t}=$(( ${X[0]}*3600 + ${X[1]}*60 + ${X[2]} ))
done
 
Old 01-13-2014, 07:20 AM   #75
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
ok, Sample files:
opt1.txt :
"OldestCallWaiting"||','||"AverageSpeedOfAnswer"||','||"CallsWaiting"||','||"CallsAnswered"||','||"C allsAbandoned"
------------------------------------------------------------------------------------------------------------------
00:01:12,01:01:52,3,2,1

opt2.txt:
"OldestCallWaiting"||','||"AverageSpeedOfAnswer"||','||"CallsWaiting"||','||"CallsAnswered"||','||"C allsAbandoned"
------------------------------------------------------------------------------------------------------------------
00:00:11,00:00:05,9,3,1

opt3.txt:
"OldestCallWaiting"||','||"AverageSpeedOfAnswer"||','||"CallsWaiting"||','||"CallsAnswered"||','||"C allsAbandoned"
------------------------------------------------------------------------------------------------------------------
00:00:16,00:00:07,7,2,1

now , how could we use it in below variables to convert the file timings into seconds
Code:
opt1_AAD=$(awk -F ',' '{ print $1 }' opt1.txt|grep '^[0-9]')
opt1_ASA=$(awk -F ',' '{ print $2 }' opt1.txt|grep '^[0-9]')
opt2_AAD=$(awk -F ',' '{ print $1 }' opt2.txt|grep '^[0-9]')
opt2_ASA=$(awk -F ',' '{ print $2 }' opt2.txt|grep '^[0-9]')
opt3_AAD=$(awk -F ',' '{ print $1 }' opt3.txt|grep '^[0-9]')
opt3_ASA=$(awk -F ',' '{ print $2 }' opt3.txt|grep '^[0-9]')
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error running cron job, syntax error? mpyusko Debian 2 12-20-2012 10:57 AM
script.pl with sed shell calls: sh error syntax error near unexpected token `(' MMaddoxx Programming 7 11-24-2011 09:00 AM
syntax error on running configure file in cygwin sugan General 1 10-08-2010 02:34 AM
why am getting error ksh: syntax error: `fi' unexpected while running script deb4you Linux - Newbie 4 09-06-2008 09:37 AM
ERROR running make when installing Nvidia drivers (syntax error) randyriver10 Linux - Software 5 02-21-2004 05:51 PM


All times are GMT -5. The time now is 04:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration