Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


wiseguy001
2014-06-05T15:48:04Z
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,
--Mike
Sponsor
Forum information
bbusse
2014-06-05T16:16:24Z
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:

{TASK(e0065463-adda-42d8-bb76-8474d0733b82,StdOut)}

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:


{TASK(e0065463-adda-42d8-bb76-8474d0733b82,StdOut)}
{TASK(041c1fba-0843-4211-8166-fb76d24de475,StdOut)}
{TASK(f7f49171-d7f5-4908-a570-44232afe8185,StdOut)}
{TASK(a3b1ed39-6ff4-4d2f-ab3b-02a65d3198fc,StdOut)}
{TASK(ace33968-2806-4476-95a5-9f4cf10d08ec,StdOut)}

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.

Brian
bbusse
2014-06-05T16:33:58Z
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.

Brian
wiseguy001
2014-06-05T18:28:28Z
Brian,

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

Thanks,
--Mike
wiseguy001
2014-07-02T03:13:13Z
Sorry for the late reply, but you do have my gratitude. The Notification /Write File solution worked great.
pgreenwood
2015-02-25T16:58:58Z
I wasn't able to get the outputfile variable to work in the email attachment? How did you get around this?
wiseguy001
2018-10-12T14:15:03Z
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