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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

`fi' unexpected error message - PLEASE HELP

Status
Not open for further replies.

RJSHA1

Programmer
Apr 12, 2001
66
GB
Hi there,
I have a shell script and I am getting a `fi' unexpected error, I have gone through the script and all the if's and fi's match up.
The only thing I can think of is that I originally wrote the script on the LAN using PFE and ftp'd it back to the Unix box and that some how there are control characters that I cannot see.

Has any one got any ideas/comments ?????
 
Have you tried dos2unix or similar conversion to make sure that any odd control chars are stripped out? I know you've checked but try a grep if and an grep fi on the file, just to be sure they all match. Post back if you need more help. Regards.
 
Hi Ken,
I've already tried them done a dos2unix and the grep check, so if you have any more ideas, I'd be grateful.

Is there anyway in vi to display control characters or hidden characters ???


Thanks

Bob...
 
what is the exact error message?

is there anything inside the if/fi block that might look suspicious/modified?

what shell interpreter are you using?

In 'vi' try ':set list' to see:
list print ^I for tab, $ at end


vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Control chars such as ^M will appear in vi by default (as far as I know). Does your script give you a line number when it encounters the problem? If so, you can vi and then set nu to quickly find the offending line and try to see what's happening. Another approach would be to vi the file and go through deleting all the ifs and fis, replacing them immediately with ifs and fis you know are correct and without any control chars. Post back letting us know how you're getting on.
 
Hi guys,
the error message is
SBS3000DPM1[152]: syntax error at line 167 : `fi' unexpected


line 152 has the code :-
if [ -r sbs3000$OPTION.dis ]


line 167 has the code :-

echo &quot;Here I am&quot;

Both lines do have fi's on the line before them.
 
give us a snippet from line 150 to line 170, pls

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Here is the code from line 150 to 170


150 fi
151 fi
152 if [ -r sbs3000$OPTION.dis ]
153 then
154 if [ $HEADER -eq &quot;Y&quot; ] then
155
156 echo &quot;Loading discard file for option $OPTION.&quot; >> $LOGFILE 2>&1
157
158 sqlldr jhy_team/jhy_team control=sbs3000_$OPTIONdis.ctrl, 159 silent=all,errors=0 >> $LOGFILE 2>&1
160 let error_code=$?
161
162 if [ $error_code -ne 0 ] then
163 echo &quot;$CTRM_JOBNAME : Failed with error code $error_code.&quot; >> $LOG
FILE 2>&1
164 echo &quot;$CTM_JOBNAME : Data file load error omto temporary tables fo
r $OPTION. &quot; >> $LOGFILE 2>&1
165 exit 1
166 fi
167 echo &quot;Here I am&quot;
168 fi
169 fi
170



Anything look glaringly obvious, or else I go through the code and replace anll the if's anf fi's
 
every of your condition like this:

if [ whatever ] then

should be:

if [ whatever ] ; then

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Hi vlad,
That works, thansk for alll your help

Bob...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top