我需要我的脚本从终端发送电子邮件。根据我在这里和网上许多其他地方看到的内容,我将其格式化如下:
/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
但是,当我运行此命令时,我收到此警告:
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
...其中第 x 行是程序中最后写入的代码行,第 y 行是/var/mail
在里面。我尝试过更换EOF
与其他事物(ENDOFMESSAGE
, FINISH
等)但无济于事。我在网上找到的几乎所有内容都是这样完成的,而且我对 bash 真的很陌生,所以我很难自己弄清楚它。有人可以提供任何帮助吗?
The EOF
token 必须位于行的开头,您不能将其与它所附带的代码块一起缩进。
If you write <<-EOF
you may indent it, but it must be indented with Tab characters, not spaces. So it still might not end up even with the block of code.
还要确保没有空格after the EOF
令牌就行了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)