Cygwin shell script

I'm trying to write a shell script (im using cygwin: Win XP) and I'm
getting an error "line 5: synatx error: unexpected end of file"

filename: asdf.sh

-----------------------------------
#! /bin/sh
if [ $# -ne 3 ]; then
echo "bla bla"
fi
-----------------------------------

I can't for the life of me figure out why, can anybody help?
zip184 [ Do, 20 Dezember 2007 23:37 ] [ ID #1891087 ]

Re: Cygwin shell script

zip184 [at] gmail.com wrote:
> I'm trying to write a shell script (im using cygwin: Win XP) and I'm
> getting an error "line 5: synatx error: unexpected end of file"
>
> filename: asdf.sh
>
> -----------------------------------
> #! /bin/sh
> if [ $# -ne 3 ]; then
> echo "bla bla"
> fi
> -----------------------------------
>
> I can't for the life of me figure out why, can anybody help?

Does Cygwin dislike CR-LF line terminators? Try saving the file with
an editor that can terminate lines with LF only. Or use commands like
dos2unix on your script file.

Janis
Janis Papanagnou [ Do, 20 Dezember 2007 23:49 ] [ ID #1891088 ]

Re: Cygwin shell script

On Dec 20, 2:37=A0pm, zip... [at] gmail.com wrote:
> I'm trying to write a shell script (im using cygwin: Win XP) and I'm
> getting an error "line 5: synatx error: unexpected end of file"
>
> filename: asdf.sh
>
> -----------------------------------
> #! /bin/sh
> if [ $# -ne 3 ]; then
> =A0 echo "bla bla"
> fi
> -----------------------------------
>
> I can't for the life of me figure out why, can anybody help?

I'm using CygWin as well on WinXP. File test.sh I created using vi:
$ cat test.sh
#! /bin/sh
if [ $# -ne 3 ]; then
echo "bla bla"
fi
if [ $# -eq 3 ]; then
echo "wow 3"
fi
$ ./test.sh 1 2 3
wow 3
$ ./test.sh
bla bla
$
Cheers,
--S
simon.greenberg [ Fr, 21 Dezember 2007 02:37 ] [ ID #1891890 ]
Linux » comp.unix.shell » Cygwin shell script

Vorheriges Thema: Getting the value of a SQL query into a shell variable
Nächstes Thema: 0403-057 Syntax error: directory is not expected.