> I'm trying to write a bash script.
> I'm using:
> ftp -n -i << END_FTP
> open $mydomain
> user $myusername $mypassword
> cd $subdirremote
> mput *
> which works fine .. UNTIL I put it inside an if statement.. then I
> get an error: line .. unexpected end of file. What would cause this?
My guess is that you're indenting the END_FTP marker. That won't
work; the shell expects to find it at the beginning of a line. So it
looks all the way to the end of the file for it, gives up, and then
can't find your closing 'fi' because it's past it already.
If you really want to indent your ending marker, you can add the same
spacing to the opening marker:
if true; then
cat << " END_FTP"
By using quotes, I added two spaces to the << marker, to match my
closing marker later.
Quote:> Maybe it would help if I understood what the << is really doing for
> me. I thought it just told the script to use the following series
> of commands until it ran across the specified string (END_FTP in
> this case) but perhaps I misunderstood.
Maybe a little. The << notation says to take the text between here
(that's why it's called a 'here' document) and the matching closing
text, and feed it to the standard input of the command. So your
example feeds those lines to the ftp process that's started. It
should work, once you fix the indentation.