Help with KSH

Hi,

I need some help with the Ksh scripting....
I have a Script call Mail.ksh which calls Crank.ksh which calls Readdates.ksh whoch calls mindiff.ksh

the output of mindiff.ksh and Readdates.ksh are wirtten to a text file...
Here is how each file is called or executed...

./Mail.ksh 30 5 ( where count=30 and wait =5)
Crank.ksh `basename ${0}` $1 $2 > ${CUR_MAINT_DATE}.out
(Where Script name=`basename ${0}` Count= $1 wait= $2 )
Readdates.ksh Load_CAG${CUR_MAINT_DATE}
(Where Load_CAG is a log file it looking up in the log dir)

 
Readdates.ksh 
 
 
# Get the Julian equivalent of the current date, subtract 1 day, convert back to a date
typeset -i LSD_DAY LSD_MONTH LSD_YEAR LSD_JUL CMD_JUL CUR_MAINT_DATE
YYYYMMDD=`date +%Y%m%d`
LSD_DAY=$(echo ${YYYYMMDD} | awk '{print substr($1,7,2)}')
LSD_MONTH=$(echo ${YYYYMMDD} | awk '{print substr($1,5,2)}')
LSD_YEAR=$(echo ${YYYYMMDD} | awk '{print substr($1,1,4)}')
LSD_JUL=$(date2julian ${LSD_DAY} ${LSD_MONTH} ${LSD_YEAR})
(( CMD_JUL = LSD_JUL - 1 ))
CUR_MAINT_DATE=$(julian2date ${CMD_JUL})
#echo "Current maintenance date is ${CUR_MAINT_DATE}"
if [ "${1}" = "" ]
then
 filnam="Load_CLM_Claim_Table"
else
 filnam="${1}"
fi
if [ ! "${2}" = "" ]
then
 CUR_MAINT_DATE="${2}"
fi
#if [ -f /devl/acbu/logs/${CUR_MAINT_DATE}/${filnam}_200*log ]
if [ -f ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log ]
then
#  ls /devl/acbu/logs/${CUR_MAINT_DATE}/${filnam}_200*log
  ls ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log
  grep 'STEP 00' ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log > r.tmp
  date1=`tail -1 r.tmp | cut -f2 -d '[' | cut -f1 -d ']'`
  grep 'Completed at \[' ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log > r.tmp
  date2=`tail -1 r.tmp | cut -f2 -d '[' | cut -f1 -d ']'`
  rm -f r.tmp
  Mindiff.ksh ${date1} ${date2}
  if [ "${3}" != "" ]
  then
    grep "${3}" ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log | head -1
  fi
else
  echo "${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log not found!\n"
fi
 

Mindiff.ksh

if [[ "${1}" = "" ]] || [[ "${2}" = "" ]]
then
  echo "Missing one or both time parameter(s).  Calc: time2 - time1"
  exit
fi
time1=${1}
timelen=$(echo ${time1} | awk '{print length($1)}')
if [[ ${timelen} = 4 ]] then
 time1="0${time1}:00"
elif [[ ${timelen} = 5 ]] then
 time1="${time1}:00"
elif [[ ${timelen} = 7 ]] then
 time1="0${time1}"
fi
time2=${2}
timelen=$(echo ${time2} | awk '{print length($1)}')
if [[ ${timelen} = 4 ]] then
 time2="0${time2}:00"
elif [[ ${timelen} = 5 ]] then
 time2="${time2}:00"
elif [[ ${timelen} = 7 ]] then
 time2="0${time2}"
fi
typeset -i hour1 min1 sec1 hour2 min2 sec2 elapsed
hour1=$(echo ${time1} | awk '{print substr($1,1,2)}')
min1=$(echo ${time1} | awk '{print substr($1,4,2)}')
sec1=$(echo ${time1} | awk '{print substr($1,7,2)}')
(( sec1 = hour1 * 60 * 60 + min1 * 60 + sec1 ))
hour2=$(echo ${time2} | awk '{print substr($1,1,2)}')
min2=$(echo ${time2} | awk '{print substr($1,4,2)}')
sec2=$(echo ${time2} | awk '{print substr($1,7,2)}')
(( sec2 = hour2 * 60 * 60 + min2 * 60 + sec2 ))
if [[ sec2 -lt sec1 ]]
then
  (( sec2 = sec2 + 24*60*60 ))
fi
(( elapsed = sec2 - sec1 ))
typeset -i hour3 min3 sec3 elapsed3
elapsed3=elapsed
(( hour3 = elapsed3 / 3600 ))
(( elapsed3 = elapsed3 - hour3 * 3600 ))
(( min3 = elapsed3 / 60 ))
(( sec3 = elapsed3 - min3 * 60 ))
hour4="${hour3}"
timelen=$(echo ${hour4} | awk '{print length($1)}')
if [[ ${timelen} = 1 ]] then
 hour4="0${hour4}"
fi
min4="${min3}"
timelen=$(echo ${min4} | awk '{print length($1)}')
if [[ ${timelen} = 1 ]] then
 min4="0${min4}"
fi
sec4="${sec3}"
timelen=$(echo ${sec4} | awk '{print length($1)}')
if [[ ${timelen} = 1 ]] then
 sec4="0${sec4}"
fi
#echo "${1}-${2} = ${time1}-${time2} = ${sec2}-${sec1} or ${elapsed} sec = ${hour4}:${min4}:${sec4}"
#echo "${1} to ${2} = ${hour4}:${min4}:${sec4}"
echo "                         ${hour4}:${min4}:${sec4} = ${1} to ${2}"
 

this whole code runs fine... Now i need another text file which have only a part of Mindiff.ksh ie the last echo (only part of it) ${hour4}:${min4}:${sec4}

i need list of this echo in a text file called runtime.out is there any possibel way to do it...

If you need more info please let me know... any suggestions are welcomed

Thanks a lot

I'm guessing you did not write that code.
code]
# change this
echo " ${hour4}:${min4}:${sec4} = ${1} to ${2}"
# to this
echo " ${hour4}:${min4}:${sec4} = ${1} to ${2}" >> runtime.out
[/code]
You will also have to add

> runtime.out

up near the top of the Mail.ksh file
[/code]

Yes i havnt written the code... Unix is not my area of field...
anways where excatly you want to to add > runtime.out
do you mean at ./Mail.ksh 30 5 > runtime.out
please correct me if i am wrong

Thanks

Actually you got my question wrong... I want the script to write to current_date.out as it is writing now... i want to add another file called runtime .out where it should only echo part of the echo statement
ie echo "${hour4}:${min4}:${sec4}"

I want this echo on a seperate file...