ts-7000
[Top] [All Lists]

[ts-7000] shell script puzzlement

To:
Subject: [ts-7000] shell script puzzlement
From: "kevin_at_newport" <>
Date: Mon, 02 May 2011 15:38:44 -0000
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/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU