• Announcements

itskytech

SwithMail update alert with log file of error

7 posts in this topic

Hi everyone,

 

I'm using Ketarin to update a large application repository in a Toolbox of a software we use at work.

It work on a server with a Windows task /silent /notify once a week.

 

For now, we receive email notification of application that has been updated with the SwithMail arguments:

/subject "Ketarin update {appname:replace:&:^&}" /body "{appname:replace:&:^&} {version:replace:&:^&}"

I'm wondering if there any simple way to get email also when an error occur on the update of an application, or maybe a command to save all errors on a log file and then we can send the attachment as well with the email?

 

I browsed this forum a lot and never find something that could achieve that.

 

 

Thanks for that really great software!

Share this post


Link to post
Share on other sites

I treat any versionless run as a failure. Sure, sometimes a failure occurs even if the version is correct, but this is the most effective testing for me.

 

So, in the global 'before updating' function I use 

if "{version}"=="" echo ERROR /// {category:replace:&:^&} /// {appname:replace:&:^&} >> somefile.txt
if "{version}"=="\{version\}" echo ERROR /// {category:replace:&:^&} /// {appname:replace:&:^&} {version:replace:&:^&} >> somefile.txt
if "{version}"=="" exit 1

In the global 'after updating an application' I use:

echo {category:replace:&:^&} /// {appname:replace:&:^&} {version:replace:&:^&} >> somefile.txt

In the global 'after updating all applications' you can use your existing command, and either attach or read in 'somefile.txt' for the body.

Share this post


Link to post
Share on other sites

Thanks for the reply!

 

I will definitely add that to my script.

 

 

EDIT: Here is what I ended up doing for this:

 

Before updating:

if "{version}"=="" echo ERROR /// {category:replace:&:^&} /// {appname:replace:&:^&} >> log.txt
if "{version}"=="\{version\}" echo ERROR /// {category:replace:&:^&} /// {appname:replace:&:^&} {version:replace:&:^&} >> log.txt
if "{version}"=="" exit 1

After updating:

echo {category:replace:&:^&} /// {appname:replace:&:^&} {version:replace:&:^&} >> log.txt

After updating all:

SwithMail.exe /s /from "YOUREMAIL@DOMAIN.COM" /name "SENDER NAME" /a "C:\Program Files (x86)\Ketarin\log.txt" /server "YOUR SMTP SERVER" /p "25" /to "RECEIVER@DOMAIN.COM" /subject "Toolbox update" /body "All application has been updated, error is in the log file attachment."
ping 1.1.1.1 -n 1 -w 10000 >nul
break > "C:\Program Files (x86)\Ketarin\log.txt"

Thought it will be nice to share the whole script if anyone need a same functionality, the log file is written at your Ketarin install folder. For the "after updating all" I use a ping to delay the clear of the log file, so the file have time to send by email before it clear out and if in any case you don't have any error, the email will send anyway because the log file is there! (Instead of deleting it each time)

Share this post


Link to post
Share on other sites

I would suggest pinging 127.0.0.1 instead if you're going to impose a delay with ping, that way you don't have to try to touch outside your network (and risk breaking any security policies you have in place). APNIC Labs might be happy for it too. :)  If you just want the delay without actual network traffic, use 0.0.0.0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now