简体   繁体   English

替代UNIX Shell脚本中的uuencode(从UNIX框发送电子邮件)

[英]substitute for uuencode in UNIX shell scripting (to send an email from UNIX box)

I have been given a task to automate a script, and I have written a script for this purpose. 我已经获得了使脚本自动化的任务,并且为此目的我编写了一个脚本。 This script needs to run from both datacentre and AWS. 该脚本需要同时从datacentre和AWS运行。 In the end the result needs to be zipped and sent to the intended recipient. 最后,需要将结果压缩并发送给预期的接收者。

I have used uuencode to generate the mail in datacentre, which runs absolutely fine in the datacentre. 我已经使用uuencode在datacentre中生成了邮件,该邮件在datacentre中运行得非常好。 However, when I run it in AWS, I am getting an error Syntax error: uuencode, not found . 但是,当我在AWS中运行它时,出现错误Syntax error: uuencode, not found

Upon searching over the internet, I came to know this is happening because the uuencode is not installed in my AWS machine. 在互联网上搜索后,我知道这是由于没有在我的AWS机器中安装uuencode而发生的。 Which is correct as I verified it. 经我验证,这是正确的。

I am new to coding, any help would really be appreciated. 我是编码新手,我们将不胜感激。 My problem here is that the AWS is a client machine where we are not supposed to install anything new. 我的问题是,AWS是一台客户端计算机,我们不应在其中安装任何新产品。 So, installing uuencode is not an option here for me. 因此,对我而言,在这里安装uuencode不是一个选择。

Can someone please let me know an alternate command for uuencode. 有人可以让我知道uuencode的替代命令吗?

Here are my linux versions: 这是我的Linux版本:

Linux AWS version: 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 AWS版本:3.8.13-55.1.2.el6uek.x86_64#2 SMP 2004年12月18日星期四00:15:51 PST 2014 x86_64 x86_64 x86_64 GNU / Linux

Linux Datacentre version: 2.6.18-194.el5 #1 SMP Mon Mar 29 22:10:29 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux Linux Datacentre版本:2.6.18-194.el5#1 SMP Mon Mar 29 22:10:29 EDT 2010 x86_64 x86_64 x86_64 GNU / Linux

and here is the piece of code I have written: 这是我编写的代码片段:

i 一世

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

I have tried mutt and sendmail command, but that did not help either. 我已经尝试过muttsendmail命令,但这也没有帮助。

Can one of you please help me out. 你们其中一个可以帮我吗? I cannot install/uninstall uuencode . 我无法安装/卸载uuencode Any alternate command would help. 任何替代命令都会有所帮助。

Regards 问候

If you need uuencode and you cannot install uuencode, then consider python. 如果您需要uuencode并且无法安装uuencode,请考虑使用python。 In modern times, python is installed everywhere and uuencode is part of one of its standard modules. 在现代,python随处可见,而uuencode是其标准模块之一。

To uuencode Report.zip and send the output to stdout, try: 要uuencode Report.zip并将输出发送到stdout,请尝试:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM