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)
>
How about adding this line as the first line?
#!/bin/sh
does it make any difference?
> 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/
|