Unexpected end of file..with csh->tcsh

All;

Thanks for reading.
I'm having a heck of a time with this cshell script that fires off an hp temperature monitor and rotates logs.
I keep getting
'/opt/temperature/temp.sh: line 22: syntax error: unexpected end of file'

when I try to 'sh /opt/temperature/temp.sh" it

--script begin-------------
#!/bin/csh -f
set tempFile = /tmp/tempfile.log #don't change this
set outfile = /opt/temperature/temperature.log
set sleeptime = 600
set maxNumLines = 24000 # maximum number of lines in the log file
set desNumLines = 18000 # desired number of lines in the log file
while (1 == 1);
do
echo `date` >> ${outfile}
/sbin/hplog -t >> ${outfile}
echo "" >> ${outfile}
sleep ${sleeptime}
set numLines = `wc -l ${outfile}|awk '{print $1}'`
if ( ${numLines} > ${maxNumLines} ); then
tail -${desNumLines} ${outfile} > ${tempFile}
mv ${tempFile} ${outfile}
endif
done

--script end-------------

Cheers..I'm sure its just a newbie error..

you cannot run a cshell script through a bourne shell interpreter.

run

csh /opt/temperature/temp.sh

or

/opt/temperature/temp.sh

Hi.

There are several Bourne shell constructs (syntax elements) that are mixed into a csh script.

Here is a version that ran through to the end. I commented out some illegal statements and added correct versions. Some assignments were made innocuous, and some statements were prefixed by echo so that I could run the entire script. Change those back for your system:

#!/bin/csh -f
# set tempFile = /tmp/tempfile.log #don't change this
# set outfile = /opt/temperature/temperature.log
set tempFile = t1
set outfile = t2
# set sleeptime = 600
set sleeptime = 1
set maxNumLines = 24000 # maximum number of lines in the log file
set desNumLines = 18000 # desired number of lines in the log file
# while (1 == 1);
while (1 == 1)
# do
echo `date` >> ${outfile}
# /sbin/hplog -t >> ${outfile}
echo /sbin/hplog -t >> ${outfile}
echo "" >> ${outfile}
sleep ${sleeptime}
set numLines = `wc -l ${outfile}|awk '{print $1}'`
# if ( ${numLines} > ${maxNumLines} ); then
if ( ${numLines} > ${maxNumLines} ) then
  tail -${desNumLines} ${outfile} > ${tempFile}
  mv ${tempFile} ${outfile}
endif
# done
end

Best wishes ... cheers, drl

---

Standard advice: avoid using csh family for scripting, use Bourne family shells instead.

All!

As is apparent, my shell skills are preety bad, but I inherited this baby, so..

Maybe I will re-do it as a bash script..

Thanks again and Happy New Year to all