cygwin on windows7

Guys,

I am new to this site and ksh scripting. I am trying to run the following code on cygwin on windows 7 but it keeps giving me syntax error. For some reason, it works on my buddies comp but not on my laptop. Done anyone know whats going on here?

#!/usr/bin/ksh
 
TXTFILE="sourcefile.txt"
#SIDN=4567
cat $TXTFILE | grep -v "#"| while read R1D
do
   echo ${R1D}
done
 

=========================

$ ./hello.ksh
: not found[2]:
./hello.ksh[11]: syntax error: 'done' unexpected
 

=================================

$ type ksh
ksh is hashed (/usr/bin/ksh)

Whats the second and last part supposed to be?
I see nothing wrong with the script (except that dollar sign is enough to display the variable)

just to show what i get as output..

the second part is the error i get when i run the script.
and the third part is to show that ksh path/installed.

I have reinstalled the shell lib under cygwin but still get this stupid error. It even complains abut blank line. as you can see ": not found[2]:" Line is to blank....

Suddenly I wonder: With what editor did you write your script?

I just tested:

#!/usr/bin/ksh

TXTFILE="203351.txt"
#SIDN=4567
cat $TXTFILE | grep -v "#"| while read R1D
do
   echo $R1D
done

Works fine...

I used both notepad++ and notepad (windows). both give same error.

Never use notepad (windows)!
Dont you have a vi in your cygwin? Because I was thinking of DOS/UNIX file format...

notepad++ works find and has worked fine. I am not sure if this is a issue of cygwin or windows7. I dont see error on my windows xp but this same code works fine on my other windows 7 machine. :wall:

If vbe is correct you should be able to clean the file using the dos2unix utility:

dos2unix hello.ksh

Then try running your script.