[Solved] List Files then Read them into variable/stdout - VisualCron - Forum

Community forum

Nvious1
2014-03-10T16:01:36Z
Been trying to figure this one out but not quite there so would like some guidance.

I have a outside app that generates text files into the outbound directory throughout the day. The VC job will run about 3 times per day to process the unknown amount of files that have been output. I want to use the list files task to list the files in that directory that meet my file mask, then turn around and use that list to read the contents into a variable that will be emailed out using the email task.

The listing the files part and the email body from the variable is all working, but I don't know how to loop through the file listing output to read the multiple files together. I considered using the concat task but I need to inject an End of Record indicator between the outputs and couldn't see how to do this.

Thoughts on how to handle this situation within VisualCron?
Support
2014-03-10T16:54:43Z
Maybe you can use the File Trigger instead, might be easier to react when the files are created and Variables are auto generated. Please look at the file trigger video here:

http://www.visualcron.com/Tutorials.aspx 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nvious1
2014-03-10T21:48:14Z
Thanks for the recommendation. I will try to use the file trigger build the process. The one concern I have is the file trigger processing a file while its still open for writing. I will try to simulate this in testing but I didn't see a way to mitigate this. I see that it states when the file is released but I am not sure this applies to how text files can be wrote to the file system.

Thanks
Support
2014-03-10T22:53:19Z
Originally Posted by: Nvious1 

Thanks for the recommendation. I will try to use the file trigger build the process. The one concern I have is the file trigger processing a file while its still open for writing. I will try to simulate this in testing but I didn't see a way to mitigate this. I see that it states when the file is released but I am not sure this applies to how text files can be wrote to the file system.

Thanks



It depends on the application that writes the file, if it locks the file during the process. Hard to say without knowing the application.

A workaround could be, if you know there is no lock on the file, is to add a Wait Task as first Task. Using a time that you know surpasses the write time. Then keep on processing with other Tasks.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nvious1
2014-03-11T17:22:42Z
Thanks for the wait task recommendation as I believe this will solve my issue.

In building out the task, I am running into the following issue.

I have the file trigger working, and then the email task. I am using the File Read Contents function to put the contents of the file into the body of the email so the body in the task just looks like this.

{FILE(Content|{TRIGGER(5df56c02-c9c8-4e30-9757-f2d2095a695d|LastTrigger|File.Result.FullPath)}|9b783802-2651-47b7-ad56-1193dbb9c35f)}

When viewing this in the variable window after the trigger has fired, it is in fact reading the file contents, however then I receive the email I get the error below.

[File->Content->Error:Object reference not set to an instance of an object.]

I am able to confirm the trigger file path value is working as it is displayed fine in the the email. Please note this is the File|Content with Credential.

I appreciate the help.
Support
2014-03-11T18:08:34Z
First, please use the activate flag for current Trigger. Something like this:

{FILE(Content|{TRIGGER(Active|LastTrigger|File.Result.FullPath)}|9b783802-2651-47b7-ad56-1193dbb9c35f)}

If that does not work maybe it is something with the Credential id?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nvious1
2014-03-11T19:15:45Z
Originally Posted by: Support 

First, please use the activate flag for current Trigger. Something like this:

{FILE(Content|{TRIGGER(Active|LastTrigger|File.Result.FullPath)}|9b783802-2651-47b7-ad56-1193dbb9c35f)}

If that does not work maybe it is something with the Credential id?



So I just tested with the Active flag and I get the same error when using the credential. The Active flag does work when no credential is used. I tested when the path was and wasn't a UNC path and the result is the same. I believe the credential works because in the variable box it is able to read the contents. The credential is also being used to allow the trigger to monitor the file path.

Thoughts or logs I can provide to help sort out this issue? Maybe this is a bug in the file|content w/ credential function?
Support
2014-03-12T10:26:25Z
Yes, it was a bug, we have now resolved this for 7.1.4:

http://www.visualcron.co....aspx?g=posts&t=3851 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top