相关疑难解决方法(0)

here-document给出'意外的文件结束'错误

我需要我的脚本从终端发送电子邮件.基于我在这里看到的以及许多其他地方的在线,我将它格式化为:

/var/mail -s "$SUBJECT" "$EMAIL" << EOF
Here's a line of my message!
And here's another line!
Last line of the message here!
EOF
Run Code Online (Sandbox Code Playgroud)

但是,当我运行这个时,我得到这个警告:

myfile.sh: line x: warning: here-document at line y delimited by end-of-file (wanted 'EOF')

myfile.sh: line x+1: syntax error: unexpected end of file
Run Code Online (Sandbox Code Playgroud)

...其中第x行是程序中最后写入的代码行,第y行是其中的行/var/mail.我试着更换EOF其他的事情(ENDOFMESSAGE,FINISH,等),但无济于事.我在网上找到的几乎所有内容都是这样做的,而且我真的很喜欢bash,所以我很难自己搞清楚.有人可以提供任何帮助吗?

email bash heredoc

64
推荐指数
3
解决办法
9万
查看次数

标签 统计

bash ×1

email ×1

heredoc ×1