Solved

Scripting E-Mail Notifications

Posted on 2004-04-27
9
190 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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