如何编写批处理文件错误/返回的免费通知脚本?
我在停止服务并重新启动它时遇到问题,希望在进程运行时收到通知并让我知道结果是什么。
这是场景, 我有一个“sc”命令的文本文件输出。 我想发送该文件,但不是作为附件。 另外,我想快速查看电子邮件主题中的初始状态。
这是“servstop.txt”文件内容:
[SC] StartService 失败 1058:
服务也无法启动 因为它被禁用或者因为它 没有关联的已启用设备 它。
我希望电子邮件的主题为“警报服务启动:[SC] StartService FAILED 1058” 以及包含上面整个错误消息的正文。
我将把我当前的方法放在下面的答案中,使用一个名为 blat 的程序向我发送结果。
I have a problem with stopping a service and starting it again and want to be notified when the process runs and let me know what the result is.
Here's the scenario,
I have a text file output of an "sc" command. I want to send that file but not as an attachment. Also, I want to see the initial status quickly in the subject of the email.
Here's the 'servstop.txt' file contents:
[SC] StartService FAILED 1058:
The service cannot be started, either
because it is disabled or because it
has no enabled devices associated with
it.
I want the subject of the email to be "Alert Service Start: [SC] StartService FAILED 1058"
and the body to contain the entire error message above.
I will put my current method in an answer below using a program called blat to send me the result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我就是这样做的。
首先,我得到 blat 邮件(公共域 smtp 邮件程序)并将其放入 d:\blat 目录中。 我的 Exchange 服务器允许我在没有 ID/密码的情况下发送电子邮件,并且只是假设我是 blat 命令的“发件人”字段中的人。
Here's how I'm doing this.
First I got blat mail (public domain smtp mailer) and dropped it into d:\blat directory. My Exchange server allows me to email without id/password and just assumes that I am the person in the 'from' field of the blat command.
Splunk 看起来很有前途。 不过还没试过。 下面是来自该网站关于索引和警报的两个块引用。
Splunk looks promising. Haven't tried it though. Two blockquotes from the site about index and alert below.