简体   繁体   English

在Unix和Linux Shell脚本中发送电子邮件

[英]sending an email in unix and linux shell scripting

I am completely new to Linux, unix shell scripting I am into new role as support analyst on shell scripting. 我对Linux和Unix Shell脚本是完全陌生的,我已经成为Shell脚本的支持分析师。 To introduce my self I am IT background but never worked with shell scripting. 为了介绍自己,我是IT背景,但从未使用过Shell脚本。 I have an idea and knowledge of basic commands but not in depth knowledge. 我对基本命令有一定的了解和知识,但对基础命令没有深入的了解。 I have a task today. 我今天有任务

To send an email from terminal we need to install mailutils package first? 要从终端发送电子邮件,我们需要首先安装mailutils软件包吗?

To alter the loop where the script detects the glassfish process is still running and send out an email after 10 attempts. 要更改脚本检测到glassfish进程仍在运行的循环,并在尝试10次后发送电子邮件。 code below 下面的代码

while [[ $glassfishPid -gt 0 ]];

do

 echo "Glassfish is running.  Killing Glassfish process..." $GlassfishPid

 kill -9 $GlassfishPid

 echo "Process killed" $GlassfishPid `date`

 GlassfishPid=`ps -ef|grep  "glassfish.jar" |grep -v grep|awk '{print $2}'`

 done

echo Glassfish shutdown at `date`.

Thank you very much 非常感谢你

echo "hello" | sendmail -f from@gmail.com -t to@yahoo. It should send Hello. 它应该发送Hello。 Let me know if it doesn't. 让我知道是否可以。

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

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