LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 11-30-2013, 05:38 AM   #1
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Rep: Reputation: Disabled
syntax error while running a script


Hi,

i am working on a ksh script where getting below error:
Error:
psd.sh:line71: [[:16:02: syntax error in expression (error token is ":02")

however line 71 in the script is:

if [[ $curr_time -ne "$fps_validated_time" ]]
then


could you please advise if need something in this if condition?
 
Old 11-30-2013, 05:47 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
This might be caused by the lack of double quotes around $curr_time:
Code:
if [[ "$curr_time" -ne "$fps_validated_time" ]]
If that doesn't work: Can you post the relevant portion of the script?

Also what is the content of curr_time and fps_validated_time variables?
 
Old 11-30-2013, 06:18 AM   #3
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
syntax error while running a script

working on a script and here is the portion of script, when run giving the above error:

Script:
#!/bin/ksh



cd /home/www/BCARD/data/psd/



curr_day=$(date +'%a')

curr_date=$(date +'%d/%m/%y')

CURR_DATE=$(date +'%Y/%m/%d')

curr_time=$(date +'%d/%m/%y %T'|awk '{ print $2 }'|awk -F ':' -v 'OFS=:' '{ print $1,$2 }')

curr_time_wit_sec=$(date +'%d/%m/%y %T'|awk '{ print $2 }'|awk -F ':' -v 'OFS=:' '{ print $1,$2":""00" }')

curr_hr=$(date +'%T'|awk -F ':' -v 'OFS=:' '{ print $1,$2 }')

curr_min=$(date +'%T'|awk -F ':' -v 'OFS=:' '{ print $2 }')





wkdaylst[1]='FPS-SCHED'

wkdaylst[2]='PODUKC-SCHED'

wkdaylst[3]='PODUKP-SCHED'

wkdaylst[4]='PODGCP-SCHED'

wkdaylst[5]='DRA-SCHED'

wkdaylst[6]='CMC-SCHED'

wkdaylst[7]='GPP-SCHED'

wkdaylst[8]='CDI-SCHED'



wkendlst[1]='FPS-SCHED'

wkendlst[2]='PODUKC-SCHED'

wkendlst[3]='PODUKP-SCHED'

wkendlst[4]='PODGCP-SCHED'

wkendlst[5]='DRA-SCHED'

wkendlst[6]='CMC-SCHED'

wkendlst[7]='GPP-SCHED'







fps_validated_status=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{print $2}')

fps_validated_date=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{print $4}')

fps_validated_time=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{print $5}' | cut -c 1-5)

fps_validated_day=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{ print $3 }')

fps_validated_hr=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{ print $5 }'| cut -c1-2)

fps_validated_min=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{ print $5 }'| cut -d ':' -f2| cut -c1-2)



if [[ $curr_day =~ "Mon" || $curr_day =~ "Tue" || $curr_day =~ "Wed" || $curr_day =~ "Thu" || $curr_day =~ "Fri" ]]

then

for i in $(seq 1 1 8)

do

#echo "${wkdaylst[$i]}"



mtch_tme=$(grep "${wkdaylst[$i]}" /home/www/BCARD/scripts/psd/psd_schedules.cfg|grep "curr_time")

echo "$mtch_tme"



if [[ $curr_date =~ "$fps_validated_date" ]]

then

if [[ -n "$mtch_tme" ]]

then

echo "$curr_time is available in configuration file..!!"

if [[ $curr_time =~ "fps_validated_time" && $fps_validated_status =~ "COMPLETED" ]]

then

echo "GREEN...!!!"

# echo " <annotation type='circle' color='8BBA00' x='100' y='65' radius='20' />" >>dp_val_v7.xml

elif [[ $curr_time =~ "fps_validated_time" && $fps_validated_status =~ "FAILED" ]]

then

echo "RED...!!!"

# echo " <annotation type='circle' color='FF0000' x='100' y='65' radius='20' />" >>dp_val_v7.xml

fi

fi



if [[ -z "$mtch_tme" ]]

then

echo "$curr_time is not available in configuration file..!!"





if [[ "$curr_time" -ne "fps_validated_time" ]]

then

rtv_dt_tmp=$(echo "$fps_validated_date $fps_validated_time ")

rtv_dt=$(echo $rtv_dt_tmp| awk -F"[ /]" '{ print "20"$3"/"$2"/"$1" "$4 ":" "00" }')



sys_time=$(echo "$CURR_DATE $curr_time_wit_sec")

let DELTA_SECONDS=(`date +%s -d "$sys_time" `-` date +%s -d "$rtv_dt"`)



delay=$(($DELTA_SECONDS / 60))

echo "Time_Dff_in_mins: $delay"



if [[ $delay -gt 5 && -lt 10 ]]

then

echo "AMBER...!!!"

elif [[ $delay -gt 10 ]]

then

echo "RED...!!!"

elif [[ $delay -le 1 ]]

then

echo"GREEN...!!!"

fi

fi

fi

fi

done

fi




also, could you please advise if needs any modification in the script?

Thanks a lot in advance :-)
 
Old 11-30-2013, 06:22 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Can you please repost the script and put [code] .. [/code] tags around it. This way the layout used is preserved (spaces etc).
 
Old 11-30-2013, 06:38 AM   #5
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
do you need in this format?:
Code:
#!/bin/ksh
cd /home/www/BCARD/data/psd/
curr_day=$(date +'%a')
curr_date=$(date +'%d/%m/%y')
CURR_DATE=$(date +'%Y/%m/%d')
curr_time=$(date +'%d/%m/%y %T'|awk '{ print $2 }'|awk -F ':' -v 'OFS=:' '{ print $1,$2 }')
curr_time_wit_sec=$(date +'%d/%m/%y %T'|awk '{ print $2 }'|awk -F ':' -v 'OFS=:' '{ print $1,$2":""00" }')
curr_hr=$(date +'%T'|awk -F ':' -v 'OFS=:' '{ print $1,$2 }')
curr_min=$(date +'%T'|awk -F ':' -v 'OFS=:' '{ print $2 }')

wkdaylst[1]='FPS-SCHED'
wkdaylst[2]='PODUKC-SCHED'
wkdaylst[3]='PODUKP-SCHED'
wkdaylst[4]='PODGCP-SCHED'
wkdaylst[5]='DRA-SCHED'
wkdaylst[6]='CMC-SCHED'
wkdaylst[7]='GPP-SCHED'
wkdaylst[8]='CDI-SCHED'

wkendlst[1]='FPS-SCHED'
wkendlst[2]='PODUKC-SCHED'
wkendlst[3]='PODUKP-SCHED'
wkendlst[4]='PODGCP-SCHED'
wkendlst[5]='DRA-SCHED'
wkendlst[6]='CMC-SCHED'
wkendlst[7]='GPP-SCHED'

fps_validated_status=$(/home/www/BCARD/data/psd/ngrep -n 3  "FPS R &amp" rtview.txt | tail -1 | awk  '{print $2}')
fps_validated_date=$(/home/www/BCARD/data/psd/ngrep -n 3  "FPS R &amp" rtview.txt | tail -1 | awk  '{print $4}')
fps_validated_time=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk  '{print $5}' | cut -c 1-5)
fps_validated_day=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{ print $3 }')
fps_validated_hr=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{ print $5 }'| cut -c1-2)
fps_validated_min=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{ print $5 }'| cut -d ':' -f2| cut -c1-2)

if [[ $curr_day =~ "Mon" || $curr_day =~ "Tue" || $curr_day =~ "Wed" || $curr_day =~ "Thu" || $curr_day =~ "Fri" ]]
then
        for i in $(seq 1 1 8)
        do
                #echo "${wkdaylst[$i]}"
                mtch_tme=$(grep "${wkdaylst[$i]}" /home/www/BCARD/scripts/psd/psd_schedules.cfg|grep "curr_time")
                echo "$mtch_tme"
                if [[ $curr_date =~ "$fps_validated_date" ]]
                then
                        if [[ -n "$mtch_tme" ]]
                        then
                                echo "$curr_time is available in configuration file..!!"
                                if [[ $curr_time =~ "fps_validated_time" && $fps_validated_status =~ "COMPLETED" ]]
                                then
                                        echo "GREEN...!!!"
        #                               echo "        <annotation type='circle' color='8BBA00' x='100' y='65' radius='20' />" >>dp_val_v7.xml
                                elif [[ $curr_time =~ "fps_validated_time"  && $fps_validated_status =~ "FAILED" ]]
                                then
                                        echo "RED...!!!"
        #                               echo "        <annotation type='circle' color='FF0000' x='100' y='65' radius='20' />" >>dp_val_v7.xml
                                fi
                        fi
 
                        if [[ -z "$mtch_tme" ]]
                        then
                                echo "$curr_time is not available in configuration file..!!"
                                 if [[ "$curr_time" -ne "fps_validated_time" ]]
                                then
                                        rtv_dt_tmp=$(echo "$fps_validated_date $fps_validated_time ")
                                        rtv_dt=$(echo $rtv_dt_tmp| awk -F"[ /]" '{ print "20"$3"/"$2"/"$1" "$4 ":" "00" }')
                                        sys_time=$(echo "$CURR_DATE $curr_time_wit_sec")
  
                                        let DELTA_SECONDS=(`date +%s -d "$sys_time" `-` date +%s -d "$rtv_dt"`)
                                        delay=$(($DELTA_SECONDS / 60))
                                        echo "Time_Dff_in_mins: $delay"
              	                                 if [[ $delay -gt 5 && -lt 10 ]]
						 then
                                                        echo "AMBER...!!!"
                                                elif [[ $delay -gt 10 ]]
                                                then
                                                        echo "RED...!!!"
                                                elif [[ $delay -le 1 ]]
                                                then
                                                        echo"GREEN...!!!"
                                                fi
                                fi
                        fi
                fi
        done
fi
 
Old 11-30-2013, 06:52 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Yep, that's a lot better!

BTW: I see you implemented the double quotes and made some other changes (line 71 isn't the one mentioned in post #1); Are you still experiencing the same error?

I'll have a better look and post anything relevant.
 
Old 11-30-2013, 07:16 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Without knowing the input and what you want/need it is rather hard to give a thorough review.

Here is the script with some comments:
Code:
#!/bin/ksh

cd /home/www/BCARD/data/psd/

curr_day=$(date +'%a')
curr_date=$(date +'%d/%m/%y')
CURR_DATE=$(date +'%Y/%m/%d')
curr_time=$(date +'%d/%m/%y %T'|awk '{ print $2 }'|awk -F ':' -v 'OFS=:' '{ print $1,$2 }')
curr_time=$( date '+%R' )
curr_time_wit_sec=$(date +'%d/%m/%y %T'|awk '{ print $2 }'|awk -F ':' -v 'OFS=:' '{ print $1,$2":""00" }')
curr_time_wit_sec=$(date '+%T' )
curr_hr=$(date +'%T'|awk -F ':' -v 'OFS=:' '{ print $1,$2 }')
curr_hr=$( date '+%H' )
curr_min=$(date +'%T'|awk -F ':' -v 'OFS=:' '{ print $2 }')
curr_min=$( date '+%M' )

wkdaylst[1]='FPS-SCHED'
wkdaylst[2]='PODUKC-SCHED'
wkdaylst[3]='PODUKP-SCHED'
wkdaylst[4]='PODGCP-SCHED'
wkdaylst[5]='DRA-SCHED'
wkdaylst[6]='CMC-SCHED'
wkdaylst[7]='GPP-SCHED'
wkdaylst[8]='CDI-SCHED'

wkendlst[1]='FPS-SCHED'
wkendlst[2]='PODUKC-SCHED'
wkendlst[3]='PODUKP-SCHED'
wkendlst[4]='PODGCP-SCHED'
wkendlst[5]='DRA-SCHED'
wkendlst[6]='CMC-SCHED'
wkendlst[7]='GPP-SCHED'

# The below entries can probably be done much simpler (one awk per line),
# but without knowing what the input is and what you are after
# I cannot give you an example
fps_validated_status=$(/home/www/BCARD/data/psd/ngrep -n 3  "FPS R &amp" rtview.txt | tail -1 | awk  '{print $2}')
fps_validated_date=$(/home/www/BCARD/data/psd/ngrep -n 3  "FPS R &amp" rtview.txt | tail -1 | awk  '{print $4}')
fps_validated_time=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk  '{print $5}' | cut -c 1-5)
fps_validated_day=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{ print $3 }')
fps_validated_hr=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{ print $5 }'| cut -c1-2)
fps_validated_min=$(/home/www/BCARD/data/psd/ngrep -n 3 "FPS R &amp" rtview.txt | tail -1 | awk '{ print $5 }'| cut -d ':' -f2| cut -c1-2)

if [[ $curr_day =~ "Mon" || $curr_day =~ "Tue" || $curr_day =~ "Wed" || $curr_day =~ "Thu" || $curr_day =~ "Fri" ]]
daysRGX='(Mon|Tue|Wed|Thu|Fri)'
if [[ $curr_day =~ $daysRGX ]]
then
  for i in $(seq 1 1 8)
  do    
    #echo "${wkdaylst[$i]}"
    mtch_tme=$(grep "${wkdaylst[$i]}" /home/www/BCARD/scripts/psd/psd_schedules.cfg|grep "curr_time")
    echo "$mtch_tme"
    if [[ "$curr_date" =~ "$fps_validated_date" ]]  # mind the double quotes
    then  
      if [[ -n "$mtch_tme" ]]
      then  
        echo "$curr_time is available in configuration file..!!"
        if [[ "$curr_time" =~ "fps_validated_time" && "$fps_validated_status" =~ "COMPLETED" ]] # mind the double quotes
        then  
          echo "GREEN...!!!"
  #             echo "        <annotation type='circle' color='8BBA00' x='100' y='65' radius='20' />"
  #             >>dp_val_v7.xml
        elif [[ "$curr_time" =~ "fps_validated_time"  && "$fps_validated_statusi" =~ "FAILED" ]] # mind the double quotes
        then  
          echo "RED...!!!"
  #             echo "        <annotation type='circle' color='FF0000' x='100' y='65' radius='20' />"
  #             >>dp_val_v7.xml
        fi    
      fi

      if [[ -z "$mtch_tme" ]]
      then
        echo "$curr_time is not available in configuration file..!!"
        if [[ "$curr_time" -ne "fps_validated_time" ]]
        then
          rtv_dt_tmp=$(echo "$fps_validated_date $fps_validated_time ") # is the extra tailing space needed?
          rtv_dt=$(echo $rtv_dt_tmp| awk -F"[ /]" '{ print "20"$3"/"$2"/"$1" "$4 ":" "00" }')
          sys_time=$(echo "$CURR_DATE $curr_time_wit_sec")
          let DELTA_SECONDS=(`date +%s -d "$sys_time" `-` date +%s -d "$rtv_dt"`)
          delay=$(($DELTA_SECONDS / 60))
          echo "Time_Dff_in_mins: $delay"
          if [[ $delay -gt 5 && -lt 10 ]]
          then
            echo "AMBER...!!!"
          elif [[ $delay -gt 10 ]]
          then
            echo "RED...!!!"
          elif [[ $delay -le 1 ]]
          then
            echo"GREEN...!!!"
          fi
        fi
      fi
    fi
  done
fi

Last edited by druuna; 11-30-2013 at 11:06 AM. Reason: fixed a typo
 
Old 12-01-2013, 12:27 AM   #8
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Here i am posting the input file and actual requirement ...
Code:
Hi, 

I'll try to explain the requirement here.

I have an input file named rtview.txt, which is actually xml file and the data in the file would be like this:
<row>

<OWNER>Sanjay</OWNER>

<AREA>CARD CONSUMER INDIA</AREA>

<GROUP>CARD (IN) TRIUMPH</GROUP>

<SERVICE>CARD (IN) TRIUMPH</SERVICE>

<KPI>BOLBPSHH - CMC R &amp; V</KPI>

<STATE>0.0</STATE>

<LASTUPDATED>1385726716217</LASTUPDATED>

<DESCRIPTION>JOB COMPLETED Fri 29/11/13 12:05</DESCRIPTION>

<SOURCE>COC</SOURCE>

<CITYPE>KPI</CITYPE>

</row>

<row>

<OWNER>Sanjay</OWNER>

<AREA>CARD CONSUMER INDIA</AREA>

<GROUP>CARD (IN) TRIUMPH</GROUP>

<SERVICE>CARD (IN) TRIUMPH</SERVICE>

<KPI>BOLBPSHA - PODUKC R &amp; V</KPI>

<STATE>0.0</STATE>

<LASTUPDATED>1385727018396</LASTUPDATED>

<DESCRIPTION>JOB COMPLETED Fri 29/11/13 12:10</DESCRIPTION>

<SOURCE>COC</SOURCE>

<CITYPE>KPI</CITYPE>

</row>

<row>

<row>

<OWNER>Satish Dubey</OWNER>

<AREA>CONSUMER INDIA</AREA>

<GROUP>CARD (IN) TRIUMPH</GROUP>

<SERVICE>CARD (IN) TRIUMPH</SERVICE>

<KPI>BLLBPSDC - FPS DEDUP &amp; SPLIT</KPI>

<STATE>0.0</STATE>

<LASTUPDATED>1385724827233</LASTUPDATED>

<DESCRIPTION>JOB COMPLETED Fri 29/11/13 11:33</DESCRIPTION>

<SOURCE>COC</SOURCE>

<CITYPE>KPI</CITYPE>

</row>

<row>

<OWNER>Sanjay</OWNER>

<AREA>CARD CONSUMER INDIA</AREA>

<GROUP>CARD (IN) TRIUMPH</GROUP>

<SERVICE>CARD (IN) TRIUMPH</SERVICE>

<KPI>BLLBTRC1 - FPS R &amp; V</KPI>

<STATE>0.0</STATE>

<LASTUPDATED>1385724812717</LASTUPDATED>

<DESCRIPTION>JOB COMPLETED Fri 29/11/13 11:33</DESCRIPTION>

<SOURCE>COC</SOURCE>

<CITYPE>KPI</CITYPE>

</row>
========================
and from the above rtview.txt file we are pulling the job status(ie. completed/failed), date and time(Time Provided in the rtview.txt is HH:MM, seconds are not provided, so i added :00 after minutes in the script manually in both variable "curr_time_wit_seconds" and "fps_validated_time" because we need to take difference of time, and if the current time is greater than 5 mins and we have not received the data according to the configuration file(i.e psd_schedules.cfg), then will show it as "AMBER" and after 10 mins if still data doesn't come in then will show it as "RED".



we have a schedular file psd.schedules.cfg,and it contains timings, usually on that mentioned time data comes in into the rtview.txt file for all the feeds(here in the script i just taken FPS related only,because once it runs successfully then we can apply logic to all the feeds).psd.schedules.cfg contains:

Configuration file:

#First column data streams

FPS-SCHED|00:30|01:30|02:30|03:30|:04:30|05:30|06:30|07:30|08:30|09:30|10:30|11:30|12:30|13:30|14:30|15:30|16:30|17:30|18:30|19:30|20:30|21:30|22:30|23:30|

PODUKC-SCHED|09:10|10:10|11:10|12:10|13:10|14:10|15:10|16:10|17:10|18:10|19:10|20:10|

PODUKP-SCHED|09:10|10:10|11:10|12:10|13:10|14:10|15:10|16:10|17:10|18:10|19:10|20:10|

PODGCP-SCHED|09:10|10:10|11:10|12:10|13:10|14:10|15:10|16:10|17:10|18:10|19:10|20:10|

DRA-SCHED|00:10|01:10|02:10|03:10|:04:10|05:10|06:10|07:10|08:10|09:10|10:10|11:10|12:10|13:10|14:10|15:10|16:10|17:10|18:10|19:10|20:10|21:10|22:10|23:10|

CMC-SCHED|00:05|01:05|02:05|03:05|:04:05|05:05|06:05|07:05|08:05|09:05|10:05|11:05|12:05|13:05|14:05|15:05|16:05|17:05|18:05|19:05|20:05|21:05|22:05|23:05|

#CDI comes once a day on week days only

CDI-SCHED|06:01|

GPP-SCHED|08:26|09:26|10:26|11:26|12:26|13:26|14:26|15:26|16:26|17:26|18:26|19:26|

#Reforma1t column

UKCREF1-SCHED|00:35|01:35|02:35|03:35|:04:35|05:35|06:35|07:35|08:35|09:35|10:35|11:35|12:35|13:35|14:35|15:35|16:35|17:35|18:35|19:35|20:35|21:35|22:35|23:35|

UKPREF1-SCHED|00:38|01:38|02:38|03:38|:04:38|05:38|06:38|07:38|08:38|09:38|10:38|11:38|12:38|13:38|14:38|15:38|16:38|17:38|18:38|19:38|20:38|21:38|22:38|23:38|

GCPREF1-SCHED|00:38|01:38|02:38|03:38|:04:38|05:38|06:38|07:38|08:38|09:38|10:38|11:38|12:38|13:38|14:38|15:38|16:38|17:38|18:38|19:38|20:38|21:38|22:38|23:38|

FIDREF1-SCHED|00:38|01:38|02:38|03:38|:04:38|05:38|06:38|07:38|08:38|09:38|10:38|11:38|12:38|13:38|14:38|15:38|16:38|17:38|18:38|19:38|20:38|21:38|22:38|23:38|

 

#Reformat2

UKCREF2-SCHED|00:50|01:50|02:50|03:50|:04:50|05:50|06:50|07:50|08:50|09:50|10:50|11:50|12:50|13:50|14:50|15:50|16:50|17:50|18:50|19:50|20:50|21:50|22:50|23:50|

UKPREF2-SCHED|00:50|01:50|02:50|03:50|:04:50|05:50|06:50|07:50|08:50|09:50|10:50|11:50|12:50|13:50|14:50|15:50|16:50|17:50|18:50|19:50|20:50|21:50|22:50|23:50|

GCPREF2-SCHED|00:50|01:50|02:50|03:50|:04:50|05:50|06:50|07:50|08:50|09:50|10:50|11:50|12:50|13:50|14:50|15:50|16:50|17:50|18:50|19:50|20:50|21:50|22:50|23:50|


now what we want is that, first we will check if the current system time matches the FPS-SCHED time in psd.schedules.cfg file, and if the current system time is suppose 00:30 for FPS-SCHED and we receive the data in rtview.txt for the same time then we will show the completed status and show it as GREEN, if the status is FAILED then we will show it as RED.

and this script runs for every 2 mins, now  if in case the FPS data has not come according to the time in configuration file, then we need to calculate the time difference, and if it is more than 5 mins then will mark as AMBER and if it is greater than 10 mins then we will mark it as RED, and and suppose after 10 mins file data comes in then will mark it as GREEN.

so, according to this i am trying to build a script, need your help...

Last edited by santosh0782; 12-01-2013 at 03:36 AM.
 
Old 12-01-2013, 04:53 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
You say you need help. With anything in particular?

In your first post you mention a specific error that showed up and I gave a possible solution for that. You never mention if this solved the original problem.

I'm willing to have a look at the script, but I do need some specific info before I can do that:
- Is ksh needed or can this be done in bash? If bash can be used: Which bash version are you using?
- Does this script run on a Linux platform or on a Unix platform (if Unix, which one)?

BTW: The [code] .. [/code] tags should be used for code and not normal text. You have to admit that reading your comments in post #8 is rather difficult.

Last edited by druuna; 12-01-2013 at 11:29 AM. Reason: fixed weird sentence
 
Old 12-01-2013, 12:07 PM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
I've had time to look at your script in more detail. The script you posted won't work as-is for different reasons.

The following is based on:
- your concept script
- ksh (should work on bash, too)
- Linux environment
- Input provided (minus the empty lines)
Code:
#!/bin/ksh
# -------------------------------------------------------------------------- #
#set -x

# Date's and locale, always interesting.
# Script is based on en_US.utf8 layout.
# Force this to make sure.
export LC_ALL="en_US.utf8"

dataDir="/home/www/BCARD/data/psd"
scriptDir="/home/www/BCARD/scripts/psd"

rtView="rtview.txt"
psdShed="psd.schedules.cfg"

curr_day=$( date +'%a' )          # Mon -> Sun
curr_date=$( date +'%d/%m/%y' )   # DD/MM/YY
CURR_DATE=$( date +'%Y/%m/%d' )   # YYYY/MM/DD
curr_time=$( date '+%R' )         # HH:MM
curr_time_wit_sec=$( date '+%T' ) # HH:MM:SS
curr_hr=$( date '+%H' )           # HH
curr_min=$( date '+%M' )          # MM

wkdaylst[1]='FPS-SCHED'
wkdaylst[2]='PODUKC-SCHED'
wkdaylst[3]='PODUKP-SCHED'
wkdaylst[4]='PODGCP-SCHED'
wkdaylst[5]='DRA-SCHED'
wkdaylst[6]='CMC-SCHED'
wkdaylst[7]='GPP-SCHED'
wkdaylst[8]='CDI-SCHED'

wkendlst[1]='FPS-SCHED'
wkendlst[2]='PODUKC-SCHED'
wkendlst[3]='PODUKP-SCHED'
wkendlst[4]='PODGCP-SCHED'
wkendlst[5]='DRA-SCHED'
wkendlst[6]='CMC-SCHED'
wkendlst[7]='GPP-SCHED'

targetArray=( $( grep -A3  "FPS R &amp" $dataDir/$rtView | tail -1 | tr '[><]' ' ' ) )
fps_validated_status=${targetArray[2]}  # COMPLETED or FAILED
fps_validated_date=${targetArray[4]}    # DD/MM/YY
fps_validated_time=${targetArray[5]}    # HH:MM
fps_validated_day=${targetArray[3]}     # Mon -> Sun
fps_validated_hr=${targetArray[5]%:*}   # HH
fps_validated_min=${targetArray[5]#*:}  # MM

if [[ "$curr_day" =~ (Mon|Tue|Wed|Thu|Fri) ]]
then
  for i in $( seq 1 1 8 )
  do
    echo "- - - ${wkdaylst[$i]} - - -"
    mtch_tme=$( grep "${wkdaylst[$i]}" $scriptDir/$psdShed | grep "$curr_time" )
    if [[ "$curr_date" == "$fps_validated_date" ]]
    then
      if [[ -n "$mtch_tme" ]]
      then
        echo "$curr_time is available in configuration file..!!"
        if [[ "$curr_time" == "$fps_validated_time" && "$fps_validated_status" == "COMPLETED" ]]
        then
          echo "GREEN...!!!"
        elif [[ "$curr_time" == "$fps_validated_time"  && "$fps_validated_status" == "FAILED" ]]
        then
          echo "RED...!!!"
        fi
      fi
      if [[ -z "$mtch_tme" ]]
      then
        echo "$curr_time is not available in configuration file..!!"
        if [[ "$curr_time" != "$fps_validated_time" ]]
        then
          rtv_dt=$( echo "$fps_validated_date $fps_validated_time" | awk -F"[ /]" '{ print "20"$3"/"$2"/"$1" "$4 ":" "00" }' )
          delay=$(( ( $(date -d "$CURR_DATE $curr_time_wit_sec" +%s ) - $( date -d "$rtv_dt" +%s ) ) / 60 ))
          echo "Time Diff in minutess: $delay"
          [[ $delay -ge 10 ]]                 && echo "RED...!!!"     # mins >= 10 
          [[ $delay -ge 5 && $delay -lt 10 ]] && echo "AMBER...!!!"   # mins >= 5 < 10
          [[ $delay -lt 5 ]]                  && echo "GREEN...!!!"   # mins < 5
        fi
      fi
    fi
  done
else
  echo "[$curr_day] Nothing to process....."
fi

exit 0

# -------------------------------------------------------------------------- #
# End
 
1 members found this post helpful.
Old 12-01-2013, 11:40 PM   #11
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Thanks a lot for all your help and time , as this script is working fine, i used all other keywords and the script is now like this:
Code:
#!/bin/ksh
# -------------------------------------------------------------------------- #
#set -x

# Date's and locale, always interesting.
# Script is based on en_US.utf8 layout.
# Force this to make sure.
export LC_ALL="en_US.utf8"

dataDir="/home/www/BCARD/data/psd"
scriptDir="/home/www/BCARD/scripts/psd"

rtView="rtview.txt"
psdShed="psd_schedules.cfg"

curr_day=$( date +'%a' )          # Mon -> Sun
curr_date=$( date +'%d/%m/%y' )   # DD/MM/YY
CURR_DATE=$( date +'%Y/%m/%d' )   # YYYY/MM/DD
curr_time=$( date '+%R' )         # HH:MM
curr_time_wit_sec=$( date '+%T' ) # HH:MM:SS
curr_hr=$( date '+%H' )           # HH
curr_min=$( date '+%M' )          # MM

wkdaylst[1]='FPS-SCHED'
wkdaylst[2]='PODUKC-SCHED'
wkdaylst[3]='PODUKP-SCHED'
wkdaylst[4]='PODGCP-SCHED'
wkdaylst[5]='DRA-SCHED'
wkdaylst[6]='CMC-SCHED'
wkdaylst[7]='CDI-SCHED'
wkdaylst[8]='GPP-SCHED'

wkendlst[1]='FPS-SCHED'
wkendlst[2]='PODUKC-SCHED'
wkendlst[3]='PODUKP-SCHED'
wkendlst[4]='PODGCP-SCHED'
wkendlst[5]='DRA-SCHED'
wkendlst[6]='CMC-SCHED'
wkendlst[7]='GPP-SCHED'

feed[1]='fps'
feed[2]='ukc'
feed[3]='ukp'
feed[4]='gcp'
feed[5]='dra'
feed[6]='cmc'
feed[7]='cdi'


feed_nme[1]='FPS R &amp'
feed_nme[2]='PODUKC R &amp'
feed_nme[3]='PODUKP R &amp'
feed_nme[4]='PODGCP R &amp'
feed_nme[5]='DRA R &amp'
feed_nme[6]='CMC R &amp'
feed_nme[7]='CDI R &amp'


if [[ "$curr_day" =~ (Mon|Tue|Wed|Thu|Fri) ]]
then
          for i in $( seq 1 1 7 )
          do
                    #echo "- - - ${wkdaylst[$i]} - - -"
                 mtch_tme=$( grep "${wkdaylst[$i]}" $scriptDir/$psdShed | grep "$curr_time" )
                targetArray=( $( grep -A3  "${feed_nme[$i]}" $dataDir/$rtView | tail -1 | tr '[><]' ' ' ) )
                a=${feed[$i]}_validated_status=${targetArray[2]}  # COMPLETED or FAILED
                b=${feed[$i]}_validated_date=${targetArray[4]}    # DD/MM/YY
                c=${feed[$i]}_validated_time=${targetArray[5]}    # HH:MM
                d=${feed[$i]}_validated_day=${targetArray[3]}     # Mon -> Sun
                e=${feed[$i]}_validated_hr=${targetArray[5]%:*}   # HH
                f=${feed[$i]}_validated_min=${targetArray[5]#*:}  # MM

        echo $a>x1
        echo $b>x2
        echo $c>x3
        echo $d>x4
        echo $e>x5
        echo $f>x6

echo "Hi"  --- loop is not executing after this....
if [[ "$curr_date" == "$x2" ]]
                    then
                              if [[ -n "$mtch_tme" ]]
                              then
                                        echo "$curr_time is available in configuration file..!!"
                                        if [[ "$curr_time" == "$x3" && "$x1" == "COMPLETED" ]]
                                        then
                                                  echo "GREEN...!!!"
                                        elif [[ "$curr_time" == "$x3"  && "$x1" == "FAILED" ]]
                                        then
                                                  echo "RED...!!!"
                                        fi
                              fi
                              if [[ -z "$mtch_tme" ]]
                              then
                                        echo "$curr_time is not available in configuration file..!!"
                                        if [[ "$curr_time" != "$x3" ]]
                                        then
                                                  rtv_dt=$( echo "$x2 $x3" | awk -F"[ /]" '{ print "20"$3"/"$2"/"$1" "$4 }' )
                                                  delay=$(( ( $(date -d "$CURR_DATE $curr_time" +%s ) - $( date -d "$rtv_dt" +%s ) ) / 60 ))
                                                  echo "Time Diff in minutess: $delay"
                                                  [[ $delay -ge 10 ]]                 && echo "RED...!!!"     # mins >= 10
                                                  [[ $delay -ge 5 && $delay -lt 10 ]] && echo "AMBER...!!!"   # mins >= 5 < 10
                                                  [[ $delay -lt 5 ]]                  && echo "GREEN...!!!"   # mins < 5
                                        fi
                              fi
                    fi
        done
else
  echo "[$curr_day] Nothing to process....."
fi
exit 0
================================
when i tun the script, it gives output as:
sh chk1.sh
Hi
Hi
Hi
Hi
Hi
Hi
Hi
=============================
need your help to execute the complete loop, could you please take a look?

Last edited by santosh0782; 12-02-2013 at 04:00 AM.
 
Old 12-02-2013, 04:14 AM   #12
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Quote:
Originally Posted by santosh0782 View Post
Thanks a lot for all your help and time , as this script is working fine
You're welcome.

Quote:
however i need another thing: Like FPS R &amp, it should check for remaining keywords from rtview.txt and find their status, time and difference and all.

other keywords are :
PODUKC R &amp
PODUKP R &amp
PODGCP R &amp
DRA R &amp
CMC R &amp
CDI R &amp
Adding an extra loop will do (see edited script below).

Quote:
sorry to bother you a lot but want to know,as we are using export LC_ALL="en_US.utf8" in the script, what it is doing?
The locale setting makes output language specific, this will influence the date, sort and other commands. Have a look at this simple example:
Code:
$ LC_TIME=nl_NL.utf8 date --date "2013/12/02 13:00:00" '+%c'
ma 02 dec 2013 13:00:00 CET

$ LC_TIME=en_US.utf8 date --date "2013/12/02 13:00:00" '+%c'
Mon 02 Dec 2013 01:00:00 PM CET
To make sure your script uses en_US.utf8 and not a different locale setting (which might be inherited from the shell it runs from) the export LC_ALL="en_US.utf8" is needed.

Code:
#!/usr/bin/ksh
# -------------------------------------------------------------------------- #
#set -x

# Date's and locale, always interesting.
# Script is based on en_US.utf8 layout.
# Force this to make sure.
export LC_ALL="en_US.utf8"

dataDir="/home/www/BCARD/data/psd"
scriptDir="/home/www/BCARD/scripts/psd"

rtView="rtview.txt"
psdShed="psd.schedules.cfg"

curr_day=$( date +'%a' )          # Mon -> Sun
curr_date=$( date +'%d/%m/%y' )   # DD/MM/YY
CURR_DATE=$( date +'%Y/%m/%d' )   # YYYY/MM/DD
curr_time=$( date '+%R' )         # HH:MM
curr_time_wit_sec=$( date '+%T' ) # HH:MM:SS
curr_hr=$( date '+%H' )           # HH
curr_min=$( date '+%M' )          # MM

wkdaylst[1]='FPS-SCHED'
wkdaylst[2]='PODUKC-SCHED'
wkdaylst[3]='PODUKP-SCHED'
wkdaylst[4]='PODGCP-SCHED'
wkdaylst[5]='DRA-SCHED'
wkdaylst[6]='CMC-SCHED'
wkdaylst[7]='GPP-SCHED'
wkdaylst[8]='CDI-SCHED'

wkendlst[1]='FPS-SCHED'
wkendlst[2]='PODUKC-SCHED'
wkendlst[3]='PODUKP-SCHED'
wkendlst[4]='PODGCP-SCHED'
wkendlst[5]='DRA-SCHED'
wkendlst[6]='CMC-SCHED'
wkendlst[7]='GPP-SCHED'

kip[1]='CDI R &amp'
kip[2]='CMC R &amp'
kip[3]='DRA R &amp'
kip[4]='FPS R &amp'
kip[5]='PODGCP R &amp'
kip[6]='PODUKC R &amp'
kip[7]='PODUKP R &amp'

for KPI in "${kip[@]}"
do

  echo "---------------> Processing: $KPI <---------------"

  targetArray=( $( grep -A3  "$KPI" $dataDir/$rtView | tail -1 | tr '[><]' ' ' ) )
  fps_validated_status=${targetArray[2]}  # COMPLETED or FAILED
  fps_validated_date=${targetArray[4]}    # DD/MM/YY
  fps_validated_time=${targetArray[5]}    # HH:MM
  fps_validated_day=${targetArray[3]}     # Mon -> Sun
  fps_validated_hr=${targetArray[5]%:*}   # HH
  fps_validated_min=${targetArray[5]#*:}  # MM
  
  if [[ "$curr_day" =~ (Mon|Tue|Wed|Thu|Fri) ]]
  then
    for i in $( seq 1 1 8 )
    do
      echo "- - - ${wkdaylst[$i]} - - -"
      mtch_tme=$( grep "${wkdaylst[$i]}" $scriptDir/$psdShed | grep "$curr_time" )
      if [[ "$curr_date" == "$fps_validated_date" ]]
      then
        if [[ -n "$mtch_tme" ]]
        then
          echo "$curr_time is available in configuration file..!!"
          if [[ "$curr_time" == "$fps_validated_time" && "$fps_validated_status" == "COMPLETED" ]]
          then
            echo "GREEN...!!!"
          elif [[ "$curr_time" == "$fps_validated_time"  && "$fps_validated_status" == "FAILED" ]]
          then
            echo "RED...!!!"
          fi
        fi
        if [[ -z "$mtch_tme" ]]
        then
          echo "$curr_time is not available in configuration file..!!"
          if [[ "$curr_time" != "$fps_validated_time" ]]
          then
            # the changes you made to the next 2 lines will not work!! I changed them back.
            rtv_dt=$( echo "$fps_validated_date $fps_validated_time" | awk -F"[ /]" '{ print "20"$3"/"$2"/"$1" "$4 ":" "00" }' )
            delay=$(( ( $(date -d "$CURR_DATE $curr_time_wit_sec" +%s ) - $( date -d "$rtv_dt" +%s ) ) / 60 ))
            echo "Time Diff in minutess: $delay"
            [[ $delay -ge 10 ]]                 && echo "RED...!!!"     # mins >= 10 
            [[ $delay -ge 5 && $delay -lt 10 ]] && echo "AMBER...!!!"   # mins >= 5 < 10
            [[ $delay -lt 5 ]]                  && echo "GREEN...!!!"   # mins < 5
          fi
        fi
      fi
    done
  else
    echo "[$curr_day] Nothing to process....."
  fi
done

exit 0

# -------------------------------------------------------------------------- #
# End
EDIT: You edited your post while I was replying. The answer given is to the un-edited version.

Last edited by druuna; 12-02-2013 at 04:15 AM.
 
Old 12-02-2013, 04:53 AM   #13
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
sorry i edited while you were replying....

now the given script is working, however the output is like this:
---------------> Processing: CMC R &amp <---------------
- - - FPS-SCHED - - -
09:45 is not available in configuration file..!!
Time Diff in minutess: 40
RED...!!!
- - - PODUKC-SCHED - - -
09:45 is not available in configuration file..!!
Time Diff in minutess: 40
RED...!!!
- - - PODUKP-SCHED - - -
09:45 is not available in configuration file..!!
Time Diff in minutess: 40
RED...!!!
- - - PODGCP-SCHED - - -
09:45 is not available in configuration file..!!
Time Diff in minutess: 40
RED...!!!
- - - DRA-SCHED - - -
09:45 is not available in configuration file..!!
Time Diff in minutess: 40
RED...!!!
- - - CMC-SCHED - - -
09:45 is not available in configuration file..!!
Time Diff in minutess: 40
RED...!!!
- - - CDI-SCHED - - -
09:45 is not available in configuration file..!!
Time Diff in minutess: 40
RED...!!!
- - - GPP-SCHED - - -
09:45 is not available in configuration file..!!
Time Diff in minutess: 40
RED...!!!

---------------> Processing: CDI R &amp <---------------
- - - FPS-SCHED - - -
09:34 is not available in configuration file..!!
Time Diff in minutess: 211
RED...!!!
- - - PODUKC-SCHED - - -
09:34 is not available in configuration file..!!
Time Diff in minutess: 211
RED...!!!
- - - PODUKP-SCHED - - -
09:34 is not available in configuration file..!!
Time Diff in minutess: 211
RED...!!!
- - - PODGCP-SCHED - - -
09:34 is not available in configuration file..!!
Time Diff in minutess: 211
RED...!!!
- - - DRA-SCHED - - -
09:34 is not available in configuration file..!!
Time Diff in minutess: 211
RED...!!!
- - - CMC-SCHED - - -
09:34 is not available in configuration file..!!
Time Diff in minutess: 211
RED...!!!
- - - CDI-SCHED - - -
09:34 is not available in configuration file..!!
Time Diff in minutess: 211
RED...!!!
- - - GPP-SCHED - - -
09:34 is not available in configuration file..!!
Time Diff in minutess: 211
RED...!!!
======================================


suppose when it is processing CDI R &amp,in that block it should display only CDI related details similar for FPS, CMS etc..

have made few changes in the script you provided:
Code:
#!/usr/bin/ksh
# -------------------------------------------------------------------------- #
#set -x

# Date's and locale, always interesting.
# Script is based on en_US.utf8 layout.
# Force this to make sure.
export LC_ALL="en_US.utf8"

dataDir="/home/www/BCARD/data/psd"
scriptDir="/home/www/BCARD/scripts/psd"

rtView="rtview.txt"
psdShed="psd_schedules.cfg"

curr_day=$( date +'%a' )          # Mon -> Sun
curr_date=$( date +'%d/%m/%y' )   # DD/MM/YY
CURR_DATE=$( date +'%Y/%m/%d' )   # YYYY/MM/DD
curr_time=$( date '+%R' )         # HH:MM
curr_time_wit_sec=$( date '+%T' ) # HH:MM:SS
curr_hr=$( date '+%H' )           # HH
curr_min=$( date '+%M' )          # MM

wkdaylst[1]='FPS-SCHED'
wkdaylst[2]='PODUKC-SCHED'
wkdaylst[3]='PODUKP-SCHED'
wkdaylst[4]='PODGCP-SCHED'
wkdaylst[5]='DRA-SCHED'
wkdaylst[6]='CMC-SCHED'
wkdaylst[7]='CDI-SCHED'
wkdaylst[8]='GPP-SCHED'

wkendlst[1]='FPS-SCHED'
wkendlst[2]='PODUKC-SCHED'
wkendlst[3]='PODUKP-SCHED'
wkendlst[4]='PODGCP-SCHED'
wkendlst[5]='DRA-SCHED'
wkendlst[6]='CMC-SCHED'
wkendlst[7]='GPP-SCHED'

kip[1]='FPS R &amp'
kip[2]='PODUKC R &amp'
kip[3]='PODUKP R &amp'
kip[4]='PODGCP R &amp'
kip[5]='DRA R &amp'
kip[6]='CMC R &amp'
kip[7]='CDI R &amp'

for KPI in "${kip[@]}"
do

  echo "---------------> Processing: $KPI <---------------"

  targetArray=( $( grep -A3  "$KPI" $dataDir/$rtView | tail -1 | tr '[><]' ' ' ) )
  validated_status=${targetArray[2]}  # COMPLETED or FAILED
  validated_date=${targetArray[4]}    # DD/MM/YY
  validated_time=${targetArray[5]}    # HH:MM
  validated_day=${targetArray[3]}     # Mon -> Sun
  validated_hr=${targetArray[5]%:*}   # HH
  validated_min=${targetArray[5]#*:}  # MM

#above i just removed the fps form fps_validated_status and others, because we have other feeds also like gcp,ukc..etc

  if [[ "$curr_day" =~ (Mon|Tue|Wed|Thu|Fri) ]]
  then
    for i in $( seq 1 1 8 )
    do
      echo "- - - ${wkdaylst[$i]} - - -"
      mtch_tme=$( grep "${wkdaylst[$i]}" $scriptDir/$psdShed | grep "$curr_time" )
      if [[ "$curr_date" == "$validated_date" ]]
      then
        if [[ -n "$mtch_tme" ]]
        then
          echo "$curr_time is available in configuration file..!!"
          if [[ "$curr_time" == "$validated_time" && "$validated_status" == "COMPLETED" ]]
          then
            echo "GREEN...!!!"
          elif [[ "$curr_time" == "$validated_time"  && "$validated_status" == "FAILED" ]]
          then
            echo "RED...!!!"
          fi
        fi
        if [[ -z "$mtch_tme" ]]
        then
          echo "$curr_time is not available in configuration file..!!"
          if [[ "$curr_time" != "$validated_time" ]]
          then
# the changes you made to the next 2 lines will not work!! I changed them back.
            rtv_dt=$( echo "$validated_date $validated_time" | awk -F"[ /]" '{ print "20"$3"/"$2"/"$1" "$4 ":" "00" }' )
            delay=$(( ( $(date -d "$CURR_DATE $curr_time_wit_sec" +%s ) - $( date -d "$rtv_dt" +%s ) ) / 60 ))
            echo "Time Diff in minutess: $delay"
            [[ $delay -ge 10 ]]                 && echo "RED...!!!"     # mins >= 10
            [[ $delay -ge 5 && $delay -lt 10 ]] && echo "AMBER...!!!"   # mins >= 5 < 10
            [[ $delay -lt 5 ]]                  && echo "GREEN...!!!"   # mins < 5
          fi
        fi
      fi
    done
  else
    echo "[$curr_day] Nothing to process....."
  fi
done

exit 0

# -------------------------------------------------------------------------- #
# End
need help to sort out this.
Thanks a lot again :-)
 
Old 12-02-2013, 05:17 AM   #14
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
The script I posted in post #10 is based on your original concept (post #5). The addition you asked for in post #11 makes me wonder if the original concept is correct.... Are there any more surprises you haven't told us about?

When time permits I'll have a look. Maybe the current script can be adjusted (might not be pretty though), but I think a re-write would be better (might take a while).
 
Old 12-02-2013, 05:47 AM   #15
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
ok, Sure, the last surprise is that we receive all feeds from Monday to Sunday except CDI as it do not come on saturday and Sunday:

weekday list( Mon to Fri)
wkdaylst[1]='FPS-SCHED'
wkdaylst[2]='PODUKC-SCHED'
wkdaylst[3]='PODUKP-SCHED'
wkdaylst[4]='PODGCP-SCHED'
wkdaylst[5]='DRA-SCHED'
wkdaylst[6]='CMC-SCHED'
wkdaylst[7]='CDI-SCHED'
wkdaylst[8]='GPP-SCHED'

weekend list (Saturday and Sunday)
(we do not receive CDI feed on Satuday and Sunday , hence we need to include this in else part)
wkendlst[1]='FPS-SCHED'
wkendlst[2]='PODUKC-SCHED'
wkendlst[3]='PODUKP-SCHED'
wkendlst[4]='PODGCP-SCHED'
wkendlst[5]='DRA-SCHED'
wkendlst[6]='CMC-SCHED'
wkendlst[7]='GPP-SCHED'


so we need to do something so that will check all the feeds from Monday to Sunday except CDI. as CDI doesn't come on Saturday and Sunday, rest all day it comes.


Thanks a lot again:-)
 
  


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:38 PM.

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