Thursday, October 14, 2010

Problems in running shell scripts on cygwin

I copied pasted this code : 
#!/usr/bin/sh
N=1
while test "$N" -le "10"
do
echo "Number $N"
  N=$[N+1]
done

in test.sh.

Then ran it like : 
./test.sh

To get : 
./test.sh: line 7: syntax error: unexpected end of file

Issue was that Windows/Dos files don't work well
as shell scripts, due to difference in new line formatting.

So, the solution is , dos2Unix convert command : 
d2u test.sh

And, that's all.
Run happily ever after.

No comments:

Blog Archive