Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm new to Unix scripting. I have created the follwing script, but it error out with following error:-
livps11:db2bws 16% archivelogbackup.ksh
archivelogbackup.ksh[45]: syntax error at line 67 : `fi' unexpected
Script is as follows:-
if [ $COUNT2 -eq 0 ] ; then <<<<<This is line 45
print $MSG3 >> $TEMP_FILE1
cat $TEMP_FILE1 >> $OUTPUT_FILE
elseif [ $COUNT1 != 0 ] then
print $MSG2 >> $TEMP_FILE2
find $BKPDIR \! -name $BKPDIR -prune -mtime -1 | xargs ls -ltr | tail -2 >> $TEMP_FILE2
cat $TEMP_FILE2 >> $OUTPUT_FILE
rmail -t "$TO_NAME" < $TEMP_FILE2
find $BKPDIR -prune -mtime 1 -exec mv {} /backup/temp \;
if [ $ARCHLOGBKPUSED -ge $SPACELIMIT ] then
print $MSG1 >> $TEMP_FILE3
cat $TEMP_FILE3 >> $OUTPUT_FILE
rmail -t "$TO_NAME" < $TEMP_FILE3
elseif
while [ $ARCHLOGBKPUSED -le $TOTALSPACE ]
do
mv $LOGARCHIVE/*.* $BKPDIR
done
fi <<<<<<<<<<This is line 67
fi

depending on your shell....
'man ksh' yields:
if list ; then list ; [ elif list ; then list ; ... ] [ else list
The list following if is executed and, if it
returns an exit status of 0, the list following
the first then is executed. Otherwise, the list
following elif is executed and, if its value is 0,
the list following the next then is executed.
Failing that, the else list is executed. If no
else list or then list is executed, then the if
command returns 0 exit status.
vlad
#include<disclaimer.h>

Hi,
I think I see more problems than just one fi
I tried to indent your script, and this is what I think is missing.
if [ $COUNT2 -eq 0 ] ;
then <<<<<This is line 45
print $MSG3 >> $TEMP_FILE1
cat $TEMP_FILE1 >> $OUTPUT_FILE
elseif [ $COUNT1 != 0 ] <--- (missing ; here )
then
print $MSG2 >> $TEMP_FILE2
find $BKPDIR \! -name $BKPDIR -prune -mtime -1 \
| xargs ls -ltr | tail -2 >> $TEMP_FILE2cat $TEMP_FILE2 >> $OUTPUT_FILE
rmail -t "$TO_NAME" < $TEMP_FILE2
find $BKPDIR -prune -mtime 1 -exec mv {} /backup/temp \;<-- (missing fi here)
if [ $ARCHLOGBKPUSED -ge $SPACELIMIT ]
then
print $MSG1 >> $TEMP_FILE3
cat $TEMP_FILE3 >> $OUTPUT_FILE
rmail -t "$TO_NAME" < $TEMP_FILE3
elseif <-- ( what's the "condition" here?? where is "then")
while [ $ARCHLOGBKPUSED -le $TOTALSPACE ]
do
mv $LOGARCHIVE/*.* $BKPDIR
done
<--- ( Missing fi here)
fi <<<<<<<<<<This is line 67fi
These things can be really common when ur writing the script for the first time.
Shoudn't the elseif be elif,
May be you just want to make conditions smaller.
just use
if [[ contition ]];
then
statemnt
else
statement
fi(NOTICE speces and [[ .)
Might help solve your problem for now. Guess ur indenting script good. It really solve 50% of the problems.
regards
cdac.

![]() |
Tranfer Unix Files
|
awk question
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |