Solved

Scripting E-Mail Notifications

Posted on 2004-04-27
9
192 Views
Last Modified: 2010-04-17
I would like to set up a batch file or script that will send out an e-mail when a Win2k server service goes down. Does anyone have any experience with scripting e-mail notifications? We are in an Win2k Ad enviornment using Exchange 2000.  
Thanks in advance for your feedback.
0
Comment
Question by:mmcginley
  • 4
  • 2
9 Comments
 
LVL 2

Expert Comment

by:TheImmortal
ID: 10928817
One of the easier things to do would be to write a simple Java Program that either used sockets directly or the JavaMail (SMTP) library.  The Batch file would call this program passing in whatever parameters the program needed.

Conversely, if you have a web server running (on the monitoring machine or elsewhere) while a FORM that submit mail (EG FormMail CGI), you could simply access the Form's URL from the batch file:

EG:
  http://myserver/servicedown.cgi?Subject=Outage&Service=MyService
0
 

Author Comment

by:mmcginley
ID: 10929180
Thanks IMMORTAL.
I actually am just looking for a batch command or script that simply sends a basic e-mail when executed. So that when one of my Win2K server Services experiences a failure, one of the recovery options can be to execute this file to send us an e-mail notification.
Thanks again.
0
 
LVL 2

Accepted Solution

by:
TheImmortal earned 63 total points
ID: 10929231
Try this then, microsoft created this port of Sendmail for Windows:

ftp://ftp.microsoft.com/developr/drg/unix-to-windows/ports/Sendmail/

This program will allow you to sendmail from the batch file without writing any other in house mail programs.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 2

Expert Comment

by:TheImmortal
ID: 10929253
PS: The archive comes complete with source code an other projects.  Use WinZIP to decompress the archive and the .TAR file inside (extract the TAR then open it with WinZIP or some other ZIP reading tool).  The Sendmail.exe is in the TAR file.
0
 
LVL 28

Assisted Solution

by:FishMonger
FishMonger earned 62 total points
ID: 10930348
Using a batch file would not be a very good choice for sending emails.  You should use one of the more powerfull scripting languages such as Perl, VB, Java, etc.  My preference would be to use Perl and one of its mail modules.  Here's a short Perl email script.

#!perl -w

use strict;
use MIME::Lite;
my $service = shift;  # Name of service that went down passed to the script as an argument.

MIME::Lite->send('smtp', "smtp.myisp.net", Timeout=>60);

my $msg = MIME::Lite->new(
                  From      =>  'me@myhost.com',
                  To          =>  'you@yourhost.com',
                  Cc          =>  'some@other.com, some@more.com',
                  Subject  =>  'Server Service',
                  Data       =>  "$service service went down"
                  );

$msg->send;


http://www.activestate.com/Products/ActivePerl/?_x=1
http://search.cpan.org/~yves/MIME-Lite-3.01/lib/MIME/Lite.pm
0
 
LVL 2

Expert Comment

by:TheImmortal
ID: 10930849
You would still have to invoke the Perl script through a Batch file or something.  Sendmail for Windows is perfectly viable.
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 10932385
I'm not sure what you mean by your first statement; wouldn't the batch file and sendmail need to be invoked by something?  I never said that Sendmail for Windows wasn't a viable option, but it still nees to be invoked by a batch file, or something.  In fact, it could be invoked within the Perl script instead of the MIME::Lite module.  BTW, your link doesn't work (at least it doesn't for me).  As I understand it, mmcginley is using some method to monitor the runnng services and if one of them stops/fails, he/she wants to call a batch file that either directly or indirectly sends an email message.  Personally, I'd combine those steps into 1 Perl script, but it can also be done with one of other scripting languages.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now