I am working on my first ksh script to review daily reports. The script uses different functions to check different types of reports in csv format. A control file gets read in with information regarding the report, other info, and the function to use.
When I run the script I get the error "syntax error at line 239 : `else' unexpected". Line 239 correlates to the 2nd red line. I had a similar problem on search function 2 before commenting it out. It read "syntax error at line 205 : `done' unexpected". Line 209 correlates to the 1st read line. Not sure why it is always the line after but that is the correct line.
Any help is appreciated!
Code:
# Seach Function for 'Multi Line - Single Field'
#search2 ()
#{
# #Remove the report header from the file. Commented out to continue troubleshooting.
# TOTALLINES=wc -1 ${RPTFILE}
# REPORTNOHEAD=$(echo ${RPTFILE} | tail -$(${TOTALLINES}-${STARTLINE}))
#
# for ERROR in $(more ${REPORTNOHEAD} | cut -f${STARTFIELD} -d ",")
# do
# if [[ ${ERROR} = ${STRING1} && ${ERROR} != ${STRINGEXCLUSION} ]];
# then
# echo "${RPTFILE} has been identified as having an error. ${INSTRUCTIONS}" >> ${ERROREMAIL}
# else
# echo "${RPTFILE} has no detected errors. >> ${APPLOG}
# fi
# done
#} # Seach Function for 'Reports that return no data, w/o "No Data Selected."'
search3 ()
{
echo "\n Search Function 3 used by ${REPORT} "
REPORTLINECOUNT=$(wc -l ${RPTFILE})
if [[ ${REPORTLINECOUNT} -ge ${STARTLINE} ]];
then
echo "${RPTFILE} has been identified as having an error. ${INSTRUCTIONS}" >> ${ERROREMAIL}
else
echo "${RPTFILE} has no detected errors. >> ${APPLOG}
fi
}
# Seach Function for 'Blank Report w/ "No Data Selected."'
search4 ()
{
echo "\n Search Function 4 used by ${REPORT} "
RPTLINE=$(more ${RPTFILE} | head -${STARTLINE} | tail -1)
RPTFIELD=$(echo ${RPTFILE} | cut -f${STARTFIELD} -d ",")
if [[ ${RPTFIELD} = ${STRING1} ]];
then
echo "${RPTFILE} has no detected errors. >> ${APPLOG}
else
echo "${RPTFILE} has been identified as having an error. ${INSTRUCTIONS}" >> ${ERROREMAIL}
echo "Error Found" >> ${APPLOG}
fi
}
#Reset Variables
LINENUMBER=0
ERRFOUND=0
#Loop through Control File
for EMAIL in $(more ${CONTROLFILE} | cut -f 2 -d ":")
do
#Grab individual Control File Line
LINENUMBER=$((${LINENUMBER} + 1))
LINE=$(more ${CONTROLFILE} | head -${LINENUMBER} | tail -1)
#set search variables
LOCATION=$(echo ${LINE} | cut -f 4 -d ":")
STARTLINE=$(echo ${LOCATION} | cut -f 1 -d "*")
STARTFIELD=$(echo ${LOCATION} | cut -f 2 -d "*")
#Variables
STRING1=$(echo ${LINE} | cut -f 3 -d ":" | cut -f 1 -d " ")
CONTROLLINENUMBER=$(echo ${LINE} | cut -f 1 -d ":")
REPORT=$(echo ${LINE} | cut -f 5 -d ":")
INSTRUCTIONS=$(echo ${LINE} | cut -f 9 -d ":")
#Find report
RPTFILE=$(find ${REPORT_DIR} -name "${REPORT}*.csv")
#Determine Search Function and use
SEARCHFUNC=$(echo ${LINE} | cut -f 8 -d ":")
case ${SEARCHFUNC} in
1) search1 ;;
2) search2 ;;
3) search3 ;;
4) search3 ;;
esac
done
Hello all,
I want to create a script that polls every hour a directory for the existence of a file. The file I look for is a `token` dropped by an external process at the completion of a successful FTP process. I wrote this script `checkfile.ksh`:
#!/usr/bin/ksh
if ] then
mailx... (5 Replies)
hi there
i write one awk script file in shell programing
the code is related to dd/mm/yy to month, day year format
but i get an error
please can anybody help me out in this problem ??????
i give my code here including error
awk `
# date-month -- convert mm/dd/yy to month day,... (2 Replies)
Hi All,
I have written a korn script (code pasted below). It is giving the error while debugging "new.sh: syntax error at line 62: `end of file' unexpected".
I have re-written the whole code in VI and explored all help related to this error on this Unix forum and tried it. Somehow, I could... (7 Replies)
I have written a shell script to Automatically FTP a file. The script runs fine when doing it manually but when I schedule it using a crontab it gives me an error.
.
.
.
echo "-----------------Starting File FTP---------------------" >> $PROS_LOAD_LOG
echo "open X.XX.XX.XXX" >>... (13 Replies)
So I am trying to convert my bash script into ksh, and this is what I have in the file so far:
#!/bin/ksh
login()
{
if
then
sendcmd BETA
else
sendcmd "$(xxd -c 32 -g 0 ${ZETA_ZETA} | awk '{print $2}')"
fi
}
But when I run it:
$ ./test.sh ... (1 Reply)
first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good.
I appreciate... (3 Replies)
Hi All,
Please hav a look at the below peice of script and let me know if there are any syntax errors.
i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong... (1 Reply)
I am getting this error Syntax error: `]' unexpected. Did I do something wrong with elif? Does ksh not like double brackets?
if ]; then
#echo hi
source ~/.bashrc;
elif ]; then
#echo hi
source ~/.kshrc;
fi (5 Replies)