Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix shell script to handle zero byte file

Status
Not open for further replies.

mnnarendra

IS-IT--Management
Mar 24, 2008
3
US
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


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top