[Solved] Email output of all tasks in job - VisualCron - Forum

Community forum

I am replacing some home grown code solutions which automates ftp retrieval, PGP encryption, and FTP delivery. I've been able to get everything to work correctly, but have been stumped by a much simpler task. I would like the last task(s) to write the output of all previous tasks into a logfile and email it to the appropriate distribution. Is there a way to do this w/o adding a "write file" after each task to capture the previous task output?

thank you,
You can do this by doing a hard reference to the TASK ID for each of the previous tasks...

Variable for one specific job would be under VisualCron Varaibles-->Jobs-->Active Job-->Tasks-->(Task1)-->Output. It'd be the 'Direct ID' radio button, for example, the variable for TASK1's StdOut would be:


So, if you have 5 tasks, you would have 5 lines with a unique ID. I'd add a 6th task, that is a write-file task. The Value would just be those 5 things all in a row, like below:


Presumably, this would result in a file with all of that data crammed into one file... to which you could send an e-mail containing the attachment.

I haven't tested this, but I see no reason why this wouldn't work.

If you don't need it to actually be a file attachment, you could just make that part of your message body of an e-mail task also.

An alternative is to use a Notification (write-File) and use it as part of the flow process.

This can get a little more fancy/tricky... :)

Also not tested, but thinking outside the box here.

Job1 - Set a new JobVariable called "OutputFilePath", set the value to your log file, i.e. C:\Temp\VisualCron\Output\Job1.txt

This variable would be called {JOB(Active,Variable,OutputFilePath)} , assuming you're referencing the active job. You would do this for all the jobs.

Now, create a new Notification (we'll create 3 total), which will be a 'Write file' task.
First notification will be named "Write Output - 1st Task only". The 'File Path' will be your variable, {JOB(Active,Variable,OutputFilePath)}
Uncheck the box for 'Append to file', which will overwrite the file. This is why we have 2 notifications. First one will erase the previous.

The 'Value' would be {TASK(PrevTask,StdOut)}

Now create a 2nd notification, same as above, called "Write Output - All other Tasks". This time, check the box for 'Append to file'.

What that does is makes a very generic notification that will use the OutputFilePath variable from the job running the notification... and write the value of the 'PreviousTask' to that file. PreviousTask, becuase the notification itself is a task... so the PreviousTask is actually the task you want.

Now, create a 3rd notification that will be an e-mail notification called "E-mail Job Output". Use variables to fill in the job name, etc... wherever you want inside the message body and/or subject. Attach a file, by using the {JOB(Active,Variable,OutputFilePath)} variable.

NOW, back to the job/tasks themselves.

Task1, edit the flow to add a 'on success' or just 'always' run Notification "Write Output - 1st Task only".

Task2, 3, 4, etc... Edit the flow on the task to run the other notification, "Write Output - All other Tasks".

On the LAST task in the job, add an additional Flow item that runs the "E-mail Job Output" Notification.

1st task will write/overwrite the log file
2nd, etc... task will append their data to the log file
Last task will also send an e-mail created by the other notifications.

As long as the variables i've mentioned work in all the screens i've mentioned, this would work quite well.


I really appreciate your quick, well thought out replies. I like the reusable nature of the 2nd reply. I'll report back my results.

Sorry for the late reply, but you do have my gratitude. The Notification /Write File solution worked great.
I wasn't able to get the outputfile variable to work in the email attachment? How did you get around this?
Just saw this (years later...) but for the sake of anyone who comes across this:

Folder: {JOB(Active,Variable,LogFileDirectory)}

Include file mask: {JOB(Active,Variable,LogFileName)}
Scroll to Top