mnnarendra
IS-IT--Management
I need the korn shell script modified to handle input files which are zero byte size and skip the processing.
The korn shell script below has three steps -
1) Extract 2 files from source system
2) Transform file
3) Load file to the Target System
This script needs to be modified to handle zero byte file from the source system. Skip the transform and loading if the filesize is zero.
#!/bin/ksh
# set -x
#############################################################Intializing log file
Path=$1
from_date=$2
to_date=$3
echo Start Extract Measure
exportData -d ${Path} -meas "WkrmC" -useLoadFormat -out $DIV_IN/wkrmc_b.ovr -range $2:$3
exportData -d ${Path} -meas "PWpCashDC" -useLoadFormat -out $DIV_IN/cashdc_b.ovr -range $2:$3
echo Start Replace with zeros
awk '{print substr($0,1,48) "0 "}' $DIV_IN/wkrmc_b.ovr > $DIV_IN/wkrmc.ovr
awk '{print substr($0,1,48) "0 "}' $DIV_IN/cashdc_b.ovr > $DIV_IN/cashdc.ovr
echo Start Load measure
loadmeasure -d ${domainPath} -meas "WkrmC" -loglevel debug >> ${LOG_FILE} 2>&1
loadmeasure -d ${domainPath} -meas "CashDC" -loglevel debug >> ${LOG_FILE} 2>&1
The korn shell script below has three steps -
1) Extract 2 files from source system
2) Transform file
3) Load file to the Target System
This script needs to be modified to handle zero byte file from the source system. Skip the transform and loading if the filesize is zero.
#!/bin/ksh
# set -x
#############################################################Intializing log file
Path=$1
from_date=$2
to_date=$3
echo Start Extract Measure
exportData -d ${Path} -meas "WkrmC" -useLoadFormat -out $DIV_IN/wkrmc_b.ovr -range $2:$3
exportData -d ${Path} -meas "PWpCashDC" -useLoadFormat -out $DIV_IN/cashdc_b.ovr -range $2:$3
echo Start Replace with zeros
awk '{print substr($0,1,48) "0 "}' $DIV_IN/wkrmc_b.ovr > $DIV_IN/wkrmc.ovr
awk '{print substr($0,1,48) "0 "}' $DIV_IN/cashdc_b.ovr > $DIV_IN/cashdc.ovr
echo Start Load measure
loadmeasure -d ${domainPath} -meas "WkrmC" -loglevel debug >> ${LOG_FILE} 2>&1
loadmeasure -d ${domainPath} -meas "CashDC" -loglevel debug >> ${LOG_FILE} 2>&1