warning: here-document delimited by end-of-file

Hi ,

My chunk of code is as follows:

create_db(){
isql -Usa -Paaa123 -S$DB_SERVER <<- BOF
 sp_addlogin $Conf, aaa123
 go
 sp_addlogin mb, aaa123
 go
 create database $Conf on $DATA_DEVICE=800 log on $LOG_DEVICE=200
 go
 online database $Conf
 BOF
isql -U$2 -Paaa123 -S$DB_SERVER -D$2 -i abc/path/etc/abc.sql
}

I keep getting the below error message

./testamb.sh: line 121: warning: here-document at line 54 delimited by end-of-file (wanted `BOF')
./testamb.sh: line 122: syntax error: unexpected end of file

Most likely, the line with BOF contains another "invisible" character. Perhaps there's a trailing space or tab character. Maybe it's a carriage return inserted by a Windows text editor or ftp transfer.

sed -n l file should reveal what's there (or od, hd, hexdump, vis).

Regards,
Alister

Remove indentation from the closing "BOF". No-one saw that because you didn't use code tags!

2 Likes

Thanks Scott the indentation was indeed the problem.But when I run this chunk of code nothing actually happens it executes but no action is performed..I was hoping that the script would logon to a Sybase server and create a database.

Your code is in a function (create_db). Did you execute that in your script?

Well ofcourse I did..

#!/bin/sh

create_db(){
isql -Usa -Paaa123 -S$DB_SERVER <<- BOF
 sp_addlogin $Conf, aaa123
 go
 sp_addlogin mb, aaa123
 go
 create database $Conf on $DATA_DEVICE=800 log on $LOG_DEVICE=200
 go
 online database $Conf
BOF
isql -U$2 -Paaa123 -S$DB_SERVER -D$2 -i abc/path/etc/abc.sql
}
create_db