NT Job Alerts

R

Raj

Hi,
Does anybody have idea as how to get notified through email or
pager when an NT job FAILS.
NT Job I mean for example: A batch file scheduled in Windows 2000 Task
Scheduler.

Thanks in advance
Rajesh
 
P

Pegasus \(MVP\)

Raj said:
Hi,
Does anybody have idea as how to get notified through email or
pager when an NT job FAILS.
NT Job I mean for example: A batch file scheduled in Windows 2000 Task
Scheduler.

Thanks in advance
Rajesh

When you say "fail" you presumably refer to a command
inside a scheduled batch file encountering some sort of
a problem. If so then you need to capture this error condition,
e.g. by its ErrorLevel. You can then invoke one of the many
public domain command line mailers (mailto, sendmail, blat)
to generate an EMail message to yourself.
 
P

Phillip Windell

Pegasus (MVP) said:
When you say "fail" you presumably refer to a command
inside a scheduled batch file encountering some sort of
a problem. If so then you need to capture this error condition,
e.g. by its ErrorLevel. You can then invoke one of the many
public domain command line mailers (mailto, sendmail, blat)
to generate an EMail message to yourself.

....and here I had a big long detailed explaination of doing just that with
"errorlevels" and commandline mailer,...then I "chickened out",...thought
there might be a more modern way that I didn't know about,...thought I'd be
"wrong" and would look stupid, and so I canceled it and didn't send it.
Bummer. It all went back to the "good 'ol days" before the Internet when I
ran an old DOS based FidoNet BBS that depended on huge batch files all over
the place and all kinds of command line utilities that were called by the
batch files. It was really "ugly" by today's standards I guess.

One thing that made me second guess myself was that I was thinking that the
"offending" Application involved in the OP's question would have had to be
written to set the errorlevel to certain particular numbers depending on
what happened when the thing ran. I didn't think that anyone would be still
alive today that would take the time to do that, so the App might not even
set the errorlevel to anything on exit,...making the errorlevel exam
worthless.
 
P

Pegasus \(MVP\)

Phillip Windell said:
...and here I had a big long detailed explaination of doing just that with
"errorlevels" and commandline mailer,...then I "chickened out",...thought
there might be a more modern way that I didn't know about,...thought I'd be
"wrong" and would look stupid, and so I canceled it and didn't send it.
Bummer. It all went back to the "good 'ol days" before the Internet when I
ran an old DOS based FidoNet BBS that depended on huge batch files all over
the place and all kinds of command line utilities that were called by the
batch files. It was really "ugly" by today's standards I guess.

One thing that made me second guess myself was that I was thinking that the
"offending" Application involved in the OP's question would have had to be
written to set the errorlevel to certain particular numbers depending on
what happened when the thing ran. I didn't think that anyone would be still
alive today that would take the time to do that, so the App might not even
set the errorlevel to anything on exit,...making the errorlevel exam
worthless.

AFAIK, each and every Command Line command generates
an errorlevel. It's a standard programming technique. If you
know any exeptions among the MS-supplied Command Line
tools then I'd be interested to know what they are.
 
R

Raj

Philip, thanks a lot for your reply. How do execute sendmail or mailto
from the command line. Is sendmail command inbuilt in Win NT or we have
to download the software from third party software website. I am not
clear on that part.
FAILS I mean for any reason due to which the job fails.

Thanks
Rajesh
 
P

Pegasus \(MVP\)

Raj said:
Philip, thanks a lot for your reply. How do execute sendmail or mailto
from the command line. Is sendmail command inbuilt in Win NT or we have
to download the software from third party software website. I am not
clear on that part.
FAILS I mean for any reason due to which the job fails.

Thanks
Rajesh

In my first reply I wrote "You can then invoke one of the many
public domain command line mailers (mailto, sendmail, blat)".
"Public domain" means that you have to download them from
various sites. Use Google to locate them!

By the way, are you really using WinNT?
 
R

Raj

Thanks for the input. I am using Win2000 Advanced server. I did
extensive research on mailto command, I couldnot find as to how to send
the mail automatically. When you create a html file it only takes you
to the mail client where you will have to manually click send to send
the message. Is there anyway I can automatically send mails.
For example in SQL server when a backup job fails it alerts me through
pager or email. In the same way if a NT job fails it should alert me
thats what I meant.

Please provide your suggestions on this
Rajesh
 
P

Pegasus \(MVP\)

Raj said:
Thanks for the input. I am using Win2000 Advanced server. I did
extensive research on mailto command, I couldnot find as to how to send
the mail automatically. When you create a html file it only takes you
to the mail client where you will have to manually click send to send
the message. Is there anyway I can automatically send mails.
For example in SQL server when a backup job fails it alerts me through
pager or email. In the same way if a NT job fails it should alert me
thats what I meant.

Please provide your suggestions on this
Rajesh

Let's have a look at the mailto command that you composed
following your extensive research, and build up on it.
 
R

Raj

<html>
<a href="mailto:[email protected]
[email protected]
&subject=Testing">
Mail to Rajesh</a>
</html>
I did extensive research for automating this, I mean this has to
automatically send mail to the concerned person, instead of waiting on
the person to click send in the mail client.

Thanks a lot for your replies
 
P

Pegasus \(MVP\)

Raj said:
<html>
<a href="mailto:[email protected]
[email protected]
&subject=Testing">
Mail to Rajesh</a>
</html>
I did extensive research for automating this, I mean this has to
automatically send mail to the concerned person, instead of waiting on
the person to click send in the mail client.

Thanks a lot for your replies

We seem to be running round in circles. Let's summarise
where we are:
1. You have a batch file that runs under the Task Scheduler.
2. You wish to be alerted when it fails.
3. I wrote that you could insert a line into your batch file, to
monitor the ErrorLevel of the critical batch file command.
4. I also wrote that depending on the ErrorLevel, you could
use a command line mailer such as mailto.exe, sendmail.exe
or blat.exe to generate an EMail note to yourself.
5. I also wrote that these tools are available in the public domain.
6. You wrote that you did extensive research on the mailto command.

We are now waiting for to show us the result of your extensive
research into the mailto command so that we can build on it
and finalise it. Let's see what you have!
 
R

Raj

Thanks again for your prompt reply. I have downloaded mailto .exe on my
machine which eventually I will be moving to the server. I am having
troubles in configuring it.
the forum says this

To install it, download MAILTO.ZIP, unzip it and then copy MAILTO.EXE
to the CGI-BIN directory of your Virtual Server.

What does the CGI-BIN directory of your Virtual server mean? Please
excuse my ignorance

So for ex: my batch file is a reboot job
psshutdown -f -r -l.
How do you incorporate mailto command here?
 
P

Pegasus \(MVP\)

Mmh. You said that you had done extensive research into
mailto.exe. I was not aware that "downloading" comes under
"extensive research" . . .

You can place mailto.exe whereever you like. It does not
matter in the least.

Your first step is now to play with mailto.exe. Try to send
a message to yourself!

The next step will be to execute mailto.exe conditionally,
e.g. like so:
@echo off
psshutdown -f -r -l > c:\shutdown.txt && goto :eof
c:\MyTools\mailto.exe /-U .. -D .. -H .. -MF c:\shutdown.txt
 
R

Raj

I am sorry "extensive research" What I meant was doing html with
mailto later recognized as mailto.exe.

How to use mailto is the question. Beacuse when I include mailto in
c:\utils (utils folder) and go to the command prompt and execute
mailto.exe it gives me an error UNKNOWN REQUEST METHOD. I would be
grateful to you if tell me how to use mailto.

Thanks a million
Rajesh
 
P

Pegasus \(MVP\)

Type

c:\utils\mailto.exe

all by itself, then add the switches as appropriate for
your environment. I can't do this for you because I am
not familiar with your environment.
 
R

Raj

I am not able to find syntax for mailto, I am not sure what those
switches mean. I would be really grateful to you if you give me a
sample batch file where in
psshutdown -f-r-l fails it should send mail to me.
when i type c:\utils\mailto.exe it says unknown request method.

I know I am really dumb, I appreciate your patience
 
P

Pegasus \(MVP\)

Raj said:
I am not able to find syntax for mailto, I am not sure what those
switches mean. I would be really grateful to you if you give me a
sample batch file where in
psshutdown -f-r-l fails it should send mail to me.
when i type c:\utils\mailto.exe it says unknown request method.

I know I am really dumb, I appreciate your patience

I suspect that getting this facility off the ground may be
outside your current field of experience. Your best bet
might be to ask a friend to assist you, someone who is
familiar with batch files. He should be able to provide
answers to these questions:

- Where does the message "Unknown request method"
come from? I have never seen such a message. Did you
translate it from some language other than English?

- What do you get when you start a Command Prompt
and type this command:
c:\>dir c:\utils\mailto.exe
Here is what you should see:
Volume in drive C is System
Volume Serial Number is 704E-AB54
Directory of C:\Utils
22/05/1998 19:45 60,928 mailto.exe

- If mailto.exe exists in the folder c:\utils and if it is
the command line mailer shown above then the command
c:\utils\mailto.exe must produce this output rather than
the message "Unknown request method":
Usage: mailto options
mailto v1.6 Copyright (c) 1998 Scott Beasley
Options are:
-U sender id -D user ids -H smtp_host
[-S subject] [-R Return path]
[-M Message] [-MF Message file name]
[-CC user ids] [-BCC user ids]
[-AB Binary file names] [-AT Text file names]
[-C config file] [-I section name]
[-RC retry count] [-RW seconds to wait between each retry]
[-DEBUG] [-N user id]

Please post again after receiving assistance from your friend.
 
R

Raj

Actually I had the wrong download of mailto that is the reason for
confusion.
when I try executing mail to from command line
c:\Utils>mailto -U ... -D ... -H .... -S It errors out
saying
Mail not sent
Error on connect
 
P

Pegasus \(MVP\)

Raj said:
Actually I had the wrong download of mailto that is the reason for
confusion.
when I try executing mail to from command line
c:\Utils>mailto -U ... -D ... -H .... -S It errors out
saying
Mail not sent
Error on connect

You must replace the dots with your own details according
to this key:
-U sender id -D user ids -H smtp_host
[-S subject] [-R Return path]
[-M Message] [-MF Message file name]
[-CC user ids] [-BCC user ids]
[-AB Binary file names] [-AT Text file names]
[-C config file] [-I section name]
[-RC retry count] [-RW seconds to wait between each retry]
[-DEBUG] [-N user id]
 
R

Raj

yeah OF CORSE I didnot enter dots, I enetered
mailto -U (e-mail address removed) -D (e-mail address removed) -H (e-mail address removed)
I get error message Error on connect.
Even the port 25 for SMTP is not blocked.

I just redirected the output of the commandI entered in the command
line to a text file this is what the text file says:
Mail not sent.
Error on connect.
 
P

Pegasus \(MVP\)

Your command is correct - I just tried it myself. If it does
not work then there is a problem with one of these elements:
- The sender address
- The receiver address
- The host name
- The authentication at the host end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top