-1

This question already has an answer here:

Here's my script

#! /bin/sh

source=/Source/$1
destination=/Destination
folderParam=$(basename $source)
if /usr/bin/rsync -avh -r $source $destination; then
   cp /FolderCopyStatus/Success   /Status/Success_$folderParam;
   mysql -h ip -uroot -ppassword  << EOF
   use oct_test;
   insert into Test(Name,Value,Status) values('rsync',$folderParam,'Ok');
   EOF
else
   cp /FolderCopyStatus/Failure   /Status/Failure_$folderParam;
   mysql -h ip  -uroot -ppassword  << EOF
   use oct_test;
   insert into Test(Name,Value,Status) values('rsync',$folderParam,'Fail');
   EOF
fi

Error and Warning

/FinalSync.sh: line 18: warning: here-document at line 8 delimited by end-of-file (wanted `EOF') /FinalSync.sh: line 19: syntax error: unexpected end of file

I know there is a simple thing that I am missing.Newbie to shell scripting.

marked as duplicate by don_crissti, ilkkachu, Satō Katsura, techraf, steeldriver Oct 18 '16 at 11:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

EOF should be placed on the start of line. Otherwise bash does not match EOF, it sees "spaces EOF".

  • So in my case where should I keep EOF? – HDev007 Oct 18 '16 at 10:28
  • At the beginning of a line. Just remove white characters preceding it. – Kalavan Oct 18 '16 at 10:33
  • 1
    Depends, one can also indent heredocs provided the right syntax is used, see here. – don_crissti Oct 18 '16 at 10:40
  • Thank you, don_crissti, for digging it up for me. I was not aware that bash can strip white characters here. – Kalavan Oct 18 '16 at 10:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.