在这里,文件最终文件的分隔 [英] here-document delimited by end-of-file

查看:110
本文介绍了在这里,文件最终文件的分隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要我的剧本,从终端发送电子邮件。根据我在这里看到和许多其他地方上网,我格式化它是这样的:

I need my script to send an email from terminal. Based on what I've seen here and many other places online, I formatted it like this:

SUBJECT="Subject line here"
EMAIL="myemail@sample.com"
/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

然而,当我运行此我得到这样的警告:

However, when I run this I get this warning:

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是在程序code最后写一行,行y是在它的/ var /信箱的线路。我试过用其他的东西(ENDOFMESSAGE,光洁度等),但无济于事更换EOF。几乎所有我在网上找到了它做这样了,我在bash中真正的新,所以我有一个很难认定它自己出去。任何人都可以提供任何帮助?谢谢!

...where line x is the last written line of code in the program, and line y is the line with /var/mail in it. I've tried replacing EOF with other things (ENDOFMESSAGE, FINISH, etc.) but to no avail. Nearly everything I've found online has it done this way, and I'm really new at bash so I'm having a hard time figuring it out on my own. Could anyone offer any help? Thanks!

推荐答案

EOF 标记必须在该行的开头,你不能随它缩进code块它会用。

The EOF token must be at the begining of the line, you can't indent it along with the block of code it goes with.

如果你写&LT;&LT; -EOF 您可以缩进,但它必须以<大骨节病>标签缩进字符,而不是空格。因此,它可能仍然没有结束,甚至与code块。

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.

另外,还要确保你没有空格 EOF 就行了标记。

Also make sure you have no whitespace after the EOF token on the line.

这篇关于在这里,文件最终文件的分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆