Syntax error `end of file' unexpected

I checked the forum and internet, tried different workaorunds but it didnt fixed the error.
Please advise on the code.

#!/bin/sh
CWD=/home/test/Bench
cd $CWD
(grep "`date +%d-%b"`" File.txt) > /home/test/Bench/dateout
if [ -s / home/test/Bench/dateout ]
then
echo �data� > /home/test/ Bench /test
else
echo "File Empty"
cat /home/test/ Bench /test > /home/test/ Bench /resultest
awk '!/get/' resultest > /home/test/ Bench/output
awk '!/0x000/' resultest > /home/test/Bench/output1
if [ -s /home/test/ Bench/output1 ]
then
MAILTO="raj@yahoo.co.in"
CONTENT="/home/test/ Bench /output1"
(
echo "Subject: Test"
echo "MIME-Version: 1.0"
echo "Content-Type: text/plain"
echo "Content-Disposition: inline"
cat $CONTENT
) | /usr/sbin/sendmail -t $MAILTO
fi
else
echo "bbb"
fi 

Do you mind indenting your script so we can understand?
e.g. Is the second if part of the first else ?
...

If it is then the before last if is not in the right place ( or the last else makes no sense...)

Now I am looking at your code (???) do you mind telling us your OS and shell?
For there are very strange stanzas ( e.g. > /home/test/ Bench /test )

Please find below the updated code, but getting the same error.

No second if is not part of first else, it is separate.

code:

CWD=/home/test/Bench
cd $CWD
(grep "`date +%d-%b"`" File.txt) > /home/test/Bench/dateout
if [ -s / home/test/Bench/dateout ]
then
echo �data� > /home/test/ Bench /test
else
echo "File Empty"
fi
cat /home/test/ Bench /test > /home/test/ Bench /resultest
awk '!/get/' resultest > /home/test/ Bench/output
awk '!/0x000/' resultest > /home/test/Bench/output1
if [ -s /home/test/ Bench/output1 ]
then
MAILTO="raj@yahoo.co.in"
CONTENT="/home/test/ Bench /output1"
(
echo "Subject: Test"
echo "MIME-Version: 1.0"
echo "Content-Type: text/plain"
echo "Content-Disposition: inline"
cat $CONTENT
) | /usr/sbin/sendmail -t $MAILTO
else
echo "bbb"
fi

Of course it will not display correctly if you continue to add fancy fonts, and I am not here to remove them all the time!

will take care of it in future pasting of codes
SunOS
/usr/bin/tcsh

( e.g. > /home/test/ Bench /test - test is user name created for testing and Bench is folder name )

I will fix and indent your script as I understand so I can read it ( poor eye sight...)
Then we will look at it OK?

Here:

#!/bin/sh
CWD=/home/test/Bench
cd $CWD
(grep "`date +%d-%b"`" File.txt) > /home/test/Bench/dateout
if [ -s / home/test/Bench/dateout ]
then
   echo �data� > /home/test/ Bench /test   
   # What are you trying to achieve here with these spaces around Bench?
else
   echo "File Empty"
fi
cat /home/test/ Bench /test > /home/test/ Bench /resultest # I like this one...
# You are doing a cat on 2 possible files and a directory?....
awk '!/get/' resultest > /home/test/ Bench/output
awk '!/0x000/' resultest > /home/test/Bench/output1  # why is there no spaces here then?
if [ -s /home/test/ Bench/output1 ]                          # but here you have ...
then
   MAILTO="raj@yahoo.co.in"
   CONTENT="/home/test/ Bench /output1"
   (
   echo "Subject: Test"
   echo "MIME-Version: 1.0"
   echo "Content-Type: text/plain"
   echo "Content-Disposition: inline"
   cat $CONTENT
   ) | /usr/sbin/sendmail -t $MAILTO
else
   echo "bbb"
fi

Before going further what do you think? my comments?

... and

(grep "`date +%d-%b"`" File.txt) > /home/test/Bench/dateout

should become

grep "`date +%d-%b`" File.txt > /home/test/Bench/dateout

Removed all the spaces from the code but still showing the error
syntax error at line 25: `end of file' unexpected

if i use

grep "`date +%d-%b`" File.txt > /home/test/Bench/dateout

it shows error

rep: can't open >
grep: can't open /home/test/Bench/dateout
grep: can't open if
grep: can't open [
grep: can't open -s
grep: can't open /home/test/Bench/dateout
grep: can't open ]

I see several lines of your code are not following tcsh syntax.

For example, in an if .. else construct I believe the expressions are put inside round bracket not square bracket.

Also an if .. else construct ends with an endif not fi

if (EXPR1) then
    ...
else if (EXPR2) then
    ...
else
    ...
endif

used in the same way but still having the same error

if (EXPR1) then
   ...
else if (EXPR2) then
   ...
else
   ...
endif 

getting the same error

syntax error at line 25: `end of file' unexpected

That was just one example. You have to do some reading on tcsh and make sure each lines in your code are tcsh compliant.

This is truely /bin/sh as stated in the 1st line.
(The user's login shell is not of interest here.)
Your grep errors below name items from the following line ... is there a problem with the line end, e.g. DOS format vs. Unix format?

If you are putting shebang as #!/bin/sh then like MadeInGermany mentioned the user's login shell does not matter.

Here is a modified code, check if it works:

#!/bin/sh
CWD="/home/test/Bench"
cd $CWD

DT=$( date +%d-%b )
if [ $( grep -c "$DT" File.txt ) -ne 0 ]
then
   echo "data" >> /home/test/Bench/test
else
   echo "File Empty"
fi
awk ' !/get/ { print $0 > "/home/test/Bench/output" } !/0x000/ { print $0 > "/home/test/Bench/output1" } ' test
if [ -s /home/test/Bench/output1 ]
then
   (
   echo "To: raj@yahoo.co.in"
   echo "Subject: Test"
   echo "MIME-Version: 1.0"
   echo "Content-Type: text/plain"
   echo "Content-Disposition: inline"
   cat /home/test/Bench/output1
   ) | /usr/sbin/sendmail -t
else
   echo "bbb"
fi

exit 0

my code also worked error was in below line

(grep "`date +%d-%b"`" File.txt) > /home/test/Bench/dateout

correct code will be

(grep "`date +"%d-%b"`" File.txt) > /home/test/Bench/dateout

i will try to use other code if it works.