哪里不对? “语法错误:意外的文件结束”

我不断收到这个错误,你们知道什么是错的吗?

rapache是重启apache的别名

 mugbear:/usr/bin# cat /usr/bin/mkdomain if [ -d "/srv/www/$1" ]; then echo "Domain $1 already exists!" else mkdir -p /srv/www/$1/public_html mkdir -p /srv/www/$1/logs cat >> /etc/apache2/sites-available/"$1" << EOF <VirtualHost removed:80> ServerAdmin support@$1 ServerName $1 ServerAlias www.$1 DocumentRoot /srv/www/$1/public_html/ ErrorLog /srv/www/$1/logs/error.log CustomLog /srv/www/$1/logs/access.log combined </VirtualHost> EOF a2ensite $1 rapache fi mugbear:/usr/bin# mkdomain test.com /usr/bin/mkdomain: line 19: syntax error: unexpected end of file 

你的heredoc永远不会结束,因为终结者不在行首。

 someFile <<EOF ... EOF 

作品


  someFile <<EOF ... EOF 

不pipe用


  someFile <<-EOF ... EOF 

作品


有关<<-EOF详细信息,请参见“ man bash ”和Bash参考手册,“3.6.6 Here Documents” 。 请注意,heredoc终止符的缩进必须使用制表符而不是空格来完成。