[英]Send multiple files by email and also add a body message to the email (Unix Korn Shell)
I'm trying to send multiple files by email but also include a body message in the email, I've tried couple of ways with no luck, the following code is for send multiple files:我正在尝试通过电子邮件发送多个文件,但也在电子邮件中包含正文消息,我尝试了几种方法但没有成功,以下代码用于发送多个文件:
(uuencode file1.txt file1.txt ; uuencode file2.txt file2.txt) | mailx -s "test" email@test.com
I've tried this option with no luck:我试过这个选项但没有运气:
echo "This is the body message" | (uuencode file1.txt file1.txt ; uuencode file2.txt file2.txt) | mailx -s "test" email@test.com
any idea how could be the code?任何想法怎么可能是代码?
Try this:尝试这个:
(echo "This is the body message"; uuencode file1.txt file1.txt; uuencode file2.txt file2.txt) | mailx -s "test" email@test.com
The issue with your command is that you are piping the output of echo
into the subshell and it is getting ignored as uuencode
isn't reading from stdin.您的命令的问题在于,您正在将
echo
的输出通过管道echo
到子外壳中,并且由于uuencode
未从 stdin 读取而被忽略。
You can use { ... }
to avoid the subshell:您可以使用
{ ... }
来避免子shell:
{ echo "This is the body message"; uuencode file1.txt file1.txt; uuencode file2.txt file2.txt; } | mailx -s "test" email@test.com
If you are doing this in a script and you want it to look more readable, then:如果您在脚本中执行此操作并且希望它看起来更具可读性,那么:
{
echo "This is the body message"
uuencode file1.txt file1.txt
uuencode file2.txt file2.txt
} | mailx -s "test" email@test.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.