dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

Cygwin shell script - shell

This is a discussion on Cygwin shell script - shell ; 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" ...


Home > Database Forum > Operating Systems > shell > Cygwin shell script

Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 12-20-2007, 06:37 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 12-20-2007, 06:49 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Cygwin shell script

zip184@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
Reply With Quote
  #3  
Old 12-20-2007, 09:37 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Cygwin shell script

On Dec 20, 2:37*pm, zip...@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?


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
Reply With Quote
  #4  
Old 08-12-2009, 06:58 PM
Database Newbie
 
Join Date: Aug 2009
Posts: 1
banana_jam is on a distinguished road
Default Re: Cygwin shell script

Hey I had this problem in Cygwin. It was the CRLF problem or end of file markers that must have done it. I used Text Pad to save the script in Linux format rather than PC format and it's fixed.
Reply With Quote
  #5  
Old 02-23-2010, 02:51 AM
Database Expert
 
Join Date: Feb 2010
Posts: 42
HENARRY JAYA is on a distinguished road
Default Re: Cygwin shell script

In the shell script file (hello_world.sh), give the full path to java.exe

For e.g., instead of
java -class path java_test_programs Hello World

type this in the hello_world.sh:
"c:\jdk\bin\java.exe" -class path java_test_programs Hello World

If that doesn't work, there are several other reasons for that error. Try the solutions given here:
I'm fairly certain \r is not white space anywhere. It is the carriage return character (similar to how one needs to throw the typewriter carriage back to its original position on a newline). Why couldn't you just use ' '?
Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 01:55 AM.