monitoring for errors via email?

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
howl
Junior Coder
Posts: 24
Joined: Tue May 29, 2007 6:41 pm

monitoring for errors via email?

Post by howl » Mon Apr 09, 2012 5:27 pm

I have a script on a trigger of "new file in folder" running on an unattended PC. Occassionaly I get an error but by the time I get to looking at the PC, there is a generic "time out waiting for user input" or something like that. Any way to have all errors sent immediately via email? Any other ideas on how to catch/monitor for the error I'm getting? The immediate notification option would be best.

Thanks

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Apr 10, 2012 5:51 am

A little more information please.

Are you using Macro Scheduler built in email capabilities or are you automating some other email client? Do you have any idea what the initial errors might be?

If you're using Macro Scheduler's RetrievePOP3> function you can monitor the variable POP3_RESULT looking for errors. Very easy then to detect an error then email that error to an email address using SMTPSendMail>

howl
Junior Coder
Posts: 24
Joined: Tue May 29, 2007 6:41 pm

Post by howl » Tue Apr 10, 2012 2:25 pm

The script in question examines the contents of a shared network folder, moves files from that folder to a different shared network folder, inserts a row into a sql server table and uses the macro scheduler smtpsendmail command to email a copy of the file to a user. I suspect the error might be in moving files from one folder to another where the same file name might already exist. I've coded to append a suffix to the file name to avoid this and that code seems to be working. Just a hunch that duplicate file names might be the problem.

Regardless of the particular issue I might be having, I would like to know if there is a way to have ANY macro notifiy me via email that it has encountered a problem. Doing that via SMTPsendmail or any other method would be great.

Thanks

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Apr 10, 2012 2:44 pm

What you're doing is interesting in that I've been working on a similar project. I'm storing the files in folders named after the users email address rather than using a database. I'm picking up email for about 120 users who do not have any other email access, then providing access to their incoming messages as files. What I haven't yet written is a fully functional email client based on the file storage rather than actual email messages. I have a group of macros written for different email like functions (reply, forward, delete, etc.) just need to pull them together.

In any case. still not enough info to give a definitive answer but... here are some possibilities for you.

If the error comes from an executable file and the executable was started by a Macro Scheduler script and the script stays open afterward, it is possible the executable will provide an error code that can be trapped by the macro scheduler script. On trapping, an email could be sent.

If the error is logged to a file the file can be periodically tested to see if it has changed. On change, an email could be sent

If the error displays a window, the window can be detected and on opening an email could be sent.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Apr 10, 2012 4:31 pm

If you want an email when any script error occurs, you could create your own error handler and use SMTPSendMail within it:

Code: Select all

Let>ONERROR=MyErrorHandler
 
..
..
 
SRT>MyErrorHandler
 SMTPSendMail>[email protected],localhost,me,me,LAST_ERROR,LAST_ERROR,   
END>MyErrorHandler
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

howl
Junior Coder
Posts: 24
Joined: Tue May 29, 2007 6:41 pm

Post by howl » Tue Apr 10, 2012 4:48 pm

ok, SRT is subroutine, I get that.
Please explain the let>ONERROR=MyErrorHandler
that looks like I'm setting a variable to MyErrorHandler and I'm not sure how that plays into this. Is ONERROR a keyword?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Apr 10, 2012 4:49 pm

Maybe this will explain it:

Code: Select all

Let>ONERROR=BIG_RED_BALLOONS
 
..
..
 
SRT>BIG_RED_BALLOONS
 SMTPSendMail>[email protected],localhost,me,me,LAST_ERROR,LAST_ERROR,   
END>BIG_RED_BALLOONS
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Apr 10, 2012 4:54 pm

Or see the error handling section in the help file. Or here:

https://www.mjtnet.com/OnlineHelp/error_handling.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

howl
Junior Coder
Posts: 24
Joined: Tue May 29, 2007 6:41 pm

Post by howl » Tue Apr 10, 2012 4:59 pm

OK thanks, now I've got it. I greatly appreciate the help.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts