Actually just realised what your problem is.
You wrote the file under Windows and transfered it to the ts7800.
The file will have DOS end of line termination which is the 2 character
sequence CR (ASCII 13) LF (ASCII 10). Linux (and unices in general)
expect lines to be terminated JUST with LF (ASCII 10).
You need to strip out the CR's.
Try this on the ts7800
$ tr -d '\015' < Helloworld.sh > Helloworld2.sh
$ chmod 755 Helloworld2.sh
$ ./Helloworld2.sh
The tr removes CR (in octal 13 is 015, "man tr" tells you about tr)
Try to write scripts on the Linux system itself.
cheers
Jim
On Mon, 2 May 2011, kevin_at_newport wrote:
> I'm trying to do something which seems simple.... write a script which
> tests for the presence/absence of a file and does something with that.
> Must be making some obvious newbie mistake.
>
> Here's my "slightly expanded from Hello World" script (line numbers added)
>
> 1: echo "Good morning, world."
> 2: #
> 3: if test -e testfile; then
> 4: echo "Found testfile";
> 5: fi
> 6: #
> 7: echo "got to the end"
> 8: (blank)
>
> If I comment out lines 3,4, and 5 the script echoes lines 1 and 7 as
> you'd expect. If I *don't* comment out lines 3,4, and 5 then I get
> "line8: syntax error: unexpected end of file"
>
> What's really puzzling is that it does what I expect when I type it in by
> hand. Here's a cut & paste from my terminal session, including the error
> message when I run the script version.
>
> :~$ if test -e testfile; then
> > echo "Found testfile";
> > fi
> Found testfile
> :~$ ./HelloWorld.sh
> Good morning, world.
> ./HelloWorld.sh: line 8: syntax error: unexpected end of file
> :~$
>
>
> What am I doing wrong?
>
>
> Kevin
>
>
>
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|