【问题标题】:substitute for uuencode in UNIX shell scripting (to send an email from UNIX box)替代 UNIX shell 脚本中的 uuencode(从 UNIX 框发送电子邮件)
【发布时间】:2016-11-03 04:15:58
【问题描述】:

我被赋予了自动化脚本的任务,为此我编写了一个脚本。此脚本需要从数据中心和 AWS 运行。最后,需要将结果压缩并发送给预期的收件人。

我使用uuencode 在数据中心生成邮件,它在数据中心运行得非常好。但是,当我在 AWS 中运行它时,我收到错误 Syntax error: uuencode, not found

在互联网上搜索后,我才知道这是因为我的 AWS 机器中没有安装 uuencode。这是正确的,因为我验证了它。

我是编码新手,任何帮助将不胜感激。我的问题是 AWS 是一台客户端机器,我们不应该在其中安装任何新东西。所以,安装uuencode 对我来说不是一个选项。

谁能告诉我另一个uuencode命令。

这是我的 linux 版本:

Linux AWS 版本:3.8.13-55.1.2.el6uek.x86_64 #2 SMP Thu Dec 18 00:15:51 PST 2014 x86_64 x86_64 x86_64 GNU/Linux

Linux 数据中心版本:2.6.18-194.el5 #1 SMP Mon Mar 29 22:10:29 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

这是我写的一段代码:

f [ -s $WORKINGDIR/Report.zip ]
then

(echo "Hi,

 Please find attached, report for datacentre.

 Please let us know for further clarifications.


Thanks,
JordanForever ";uuencode $WORKINGDIR/Report.zip Report.zip;)| mailx -s "report for datacentre " $MAILLIST
else
(echo "script for datacentre failed.

        Script Details:

                Host: $HOSTNAME
                Path: $WORKINGDIR

";) | mailx -s "Failed: report for datacentre " $FAILURE_MAILLIST
fi

我尝试过muttsendmail 命令,但也没有用。

请你们中的一个人帮帮我。我无法安装/卸载uuencode。任何替代命令都会有所帮助。

问候

【问题讨论】:

  • 我假设您已经检查过您在 AWS 上实施的 mailx 实际上没有附加(因此编码)附件的选项?寻找-A(或类似选项),但不是每个mailx 都有这个。
  • base64 可用吗?如果是这样,它会对数据进行 Base-64 编码(和解码)。它与uuencode 不同(它不包括文件名和权限信息,您可能希望指定-b 72 或类似的位置——GNU 版本的-w 72——以合理地打破界限等)。它是“现代”标准编码,避免了uuencode 诸如输出行尾随空格之类的讨厌(如果删除,uudecode 会中断)。

标签: shell unix scripting uuencode


【解决方案1】:

如果你需要 uuencode 而你无法安装 uuencode,那么考虑使用 python。在现代,python 无处不在,uuencode 是其标准模块之一。

要对Report.zip 进行uuencode 并将输出发送到标准输出,请尝试:

python -c 'import sys,uu; uu.encode("Report.zip", sys.stdout)'

【讨论】:

    猜你喜欢
    • 2016-05-05
    • 2010-12-19
    • 1970-01-01
    • 2011-04-19
    • 2018-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多