I am new at the korn shell and have inherited a script i am trying to make work the errors im getting are as follows:
ERRORS
+ pa_batching.ksh
pa_batching.ksh: factset: not found
pa_batching.ksh[9]: automation.: not found
pa_batching.ksh[22]: CT: not found
pa_batching.ksh[24]: syntax error at line 52 : `for' unmatched
The script itself is as below , it is a batch processing script
ANY IDEAS AS TO WHERE I SHOULD LOOK?
SCRIPT
factset $ more pa_batching.ksh
#! /bin/ksh
#
# Filename: factset_transfer
#
# Author: Steven bowskill
#
# Description: This file is the main script for the PA BATCHING FactSet
automation.
#
#
#-------------------------------------------------------------------------------
#set -vx
exit_handler()
{
printLog "$1: $2"
exit $1
}
#FUNCTION TO SEARCH FOR THE CORRECT NAME OF THE FILE AND PLACE THEM IN THE CORRE
CT DIRECOTRY
function getfilesandcopy
{
##set up some vars
paftpPramFile='pa_batch_put.cfg'
paremote_node=lon-ks-util01
paremote_user=ftpwilshire
paremote_password=wilshire
paftpcommand=PUT
pafileExt=
paftptransmethod=binary
##export them now
export paremote_node
export paremote_user
export paremote_password
export paftpcommand
export pafileExt
export paftptransmethod
export paftpPramFile
\#create the file of the xls file in then this file will also con
tain the accounts
awk -F']' '/]/ \{print $2\}' $1 > $palocal_check/factserepor
ts.txt
\# now go thru this file lookgin for the account
for acct in \`cat $palocal_check/factsereports.txt\`
do
echo "Start to search \**********************************
****************************"
\#get the factset file
filetoDownload=\`echo $acct | awk -F',' '\{print $1\}'
`
\#get the xls file to download
XlsfiletoDownload=\`echo $acct | awk -F',' '\{print $
1}'`
filetoDownload=\`echo $acct | awk -F',' '\{print $2\}'
`
filetoDownload=`echo $f
iletoDownload | awk -F'' '{print $1"_"$2"_"$3""$4}'`
printLog "searching for $\{filetoDownload\}"
cut -d "/" -f2-10 $palocal_check/dirs.txt > $palocal_check/dirsfound.txt
cat $palocal_check/dirsfound
d.txt
\#\#get the correct name of the file from the dirs.txt fi
le
## NewFileToCopy=`awk -F, '/
'$filetoDownload'/ {print $3}' $palocal_check/dirs.txt`
\#\#echo $NewFileToCopy
DirectoryFound=\`cat $palocal_check/dirsfound.txt\`
\#did we get a match
if [ ! -z $\{DirectoryFound\} ] ;
then
while read dirs
do
\#now ch
eck the file exists here
printLo
g xls file $XlsfiletoDownload
if [ -f ${XlsfiletoDownload} ] ; then
\#first lets r
ename the factset file
# cp ${palocal_check}/$XlsfiletoDownload ${palocal_check}/${filetoDownload}
.xls
\#\#now need to ftp the file from sun42 to
the g drive
\#\#set up the ftp vars
padataname=$XlsfiletoDownload
paremote_dir=$dirs
palocal_dir=$palocal_check
\#export the vars
export padataname
export paremote_dir
export palocal_dir
\# now ftp the file
printLog "Ftp $\{filetoDownload\} to $\{dir
s} this is the factset file ${XlsfiletoDownload} "
ftpfile
\#copy the xls file
cp $\{palocal_check\}/$XlsfiletoDownload $\{p
alocal_check}/${filetoDownload}.xls
#now delete the xls file from factset this will
tell us what was not found
rm ${pa
local_check}/$XlsfiletoDownload
fi
done <
$palocal_check/dirsfound.txt
else
continue
fi
echo "Finish search \**********************************
****************************"
echo
echo
done
}
# FUNCTION TO UNZIP THE FILES FTP'D FROM THE FACTSET SERVER
#-------------------------------------------------------------------------------
function unzipfile
{
unzip -ql $palocal_check/$1
}
#-------------------------------------------------------------------------------
#FUNCTION TO FTP THE ZIP FILE, WE CAN NOT USE LIST AS FACTSET DOES NOT ALLOW IT
# SO WE HAVE TO GET THE FILES ONE BY ONE
#-------------------------------------------------------------------------------
function ftpzipfiles
{
#set up the zip ext as we are always going to use this
pafileExt='.ZIP'
export pafileExt
paftptransmethod=bin
export paftptransmethod
lnCount=1
for filename in `cat ${palocal_check}/1global_daily.tag_zip`
do
let lnCount=lnCount+1
# if [ ${lnCount} -eq 26 ] ; then
if [ ${lnCount} -lt 5 ] ; then
filenametodownload=\`echo $filename | awk -F'.' '\{print $1\}'\`
padataname=$\{filenametodownload\}
export padataname
\#ftp the file from the factset server
ftpfile
\#unzip the file
cd $palocal_check
unzip -qo $palocal_check/$filename
fi
done
}
#FUNCTION TO PRINT THE MESSAGES TO THE LOG FILE
#-------------------------------------------------------------------------------
printLog()
{
print "`date '+%H:%M:%S'`> $1"
return
}
#-------------------------------------------------------------------------------
# Set up basic environment
#delete the log file we want a clean one
rm /opt/lonsched/log/pabatching.log
#set the log file up
logfile=/opt/lonsched/log/pabatching.log
[ -z ${logfile} ] && logfile=/dev/tty
export logfile
exec 1>> ${logfile}
exec 2>&1
printLog "Setting environment parameters .." date
. /opt/lonsched/scripts/factset/pabatching_params.ksh
let retstat=$?
if [ ${retstat} -ne 0 ] ; then
exit_handler 101 "Failed to set up environment - unknown mode setting"
fi
# Derive the data file name from the tag file name and make it
# available to runFTP.
#
#lcDate=`date +"%d%b%Y" | tr "[a-z]" "[A-Z]"`
lcDate="04OCT2004"
#set up the vars and cal the ftp function
paftpPramFile='pa_batch_get.cfg'
paftpcommand=GET
padataname=1global_daily_$lcDate
pafileExt=.tag_zip
paftptransmethod=ascii
#export the vars
export paftpcommand
export padataname
export pafileExt
export paftptransmethod
#call the ftp function
ftpfile
##get the second tag_zip file
padataname=2global_daily_$lcDate
export padataname
pafileExt=.tag_zip
export pafileExt
#call the ftp function
#ftpfile
##more more the lst file into the first tag_zip this wil give us the whole list
of zip file to ftp over
more $\{palocal\_check\}/2global\_daily.tag_zip >> $\{palocal\_check\}/1global_
daily.tag_zip
##change the windows file to UNIX
copyWinToUnix
#We now need to bring down all the zip files listed within the /1global_daily.t
ag_zip file
ftpzipfiles
##This is where we do the searching and placing of the files from the dirs.txt .
...
##first set up the vars
printLog "PROCESSING THE FIRST FILE "
padataname=1global_daily
export padataname
pafileExt=.tag
export pafileExt
getfilesandcopy ${palocal_check}/${padataname}.tag
ANY IDEAS AS TO WHERE I SHOULD LOOK?