SFTP or Archive a SPECIFIC file and report error if not found - VisualCron - Forum

Community forum

bbusse
2011-08-08T15:49:21Z
Hey guys,

I've had VisualCron since 4.6.16 (i think) but I have honestly never used any more advanced functions other than the basic Execute task and maybe a few conditions and notifications so I may just be missing something here, but I have a process i'd like to build natively into visualcron instead of scripting it and thought i'd ask how i'd go about accomplishing this. i'll keep it in the context of an SFTP transfer and an archive (ahead of time) to help explain what my goals are:


2:30pm each day I want to take c:\temp\FileToUpload.csv and copy it (or archive/zip/etc..) to c:\temp\FileToUpload_DATE_TIME.csv
File Copy does not appear to have the ability to do a one to one source file name and a different destination file name (as I want it renamed to contain a date so I can keep history in one folder) I know a rename task can do this but it removes the original file in the process.

2:30pm each day, assuming the previous 'Archive' step was successfull, I want to SFTP a very specific file (c:\temp\FileToUpload.csv) (always the same name, updated daily) to a 3rd party customer. In the file mask for the SFTP connection I put the exact file name in and this works but since I cannot specify a SPECIFIC file name, only a file mask, the process is always successfull whether or not a file is actually sent or not. I want it to 'Error Out' if c:\temp\FileToUpload.csv does not exist or for any other reason the file doesn't get uploaded via SFTP, but its always coming back as a success.


So, I have 2 ways I was wanting to do this. Copy (using different destination name) to the Archive folder and if successful, run the SFTP process to upload it.

OR

SFTP the file to the 3rd party customer (leaving original file in place) and then do a RENAME File operation task that would effectively move the file while renaming it.


Anyone have any other suggestions? Ideally both the 'Archive' step and the 'SFTP' step would be able to know there was a problem. Hopefully i've explained what I want in a way that makes sense. I could always just write a powershell script to handle all this but I thought i'd use the built-in functionality, if possible.

Brian
Support
2011-08-08T17:57:06Z
Hi,

by archiving you just want to make a copy of a file? Or perhaps, the easiest way is just renaming the file using the File Rename Task. If you want to rename it the target file could be:

FileToUpload_{DATEFORMAT(yyyy-MM-dd)}.csv

You could adjust the date parameters yourself depending on what you want.

About SFTP:ing a file. If the file itself goes to a certain folder you could use the File Trigger to watch for new files and then FTP the file. Here is one example of this:

http://www.visualcron.com/Tutorials.aspx 

Maybe this information will help you to provide further detailed questions.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
bbusse
2011-08-08T18:41:08Z
I am not having any trouble Renaming a file or SFTP'ing a file. The problem i'm having is I have no way to have the 'copy file' operation Fail, if the file didn't exist as the copy operation does not care if it doesn't exist, its just using a wildcard (File mask) and if there's nothing to copy, it just says 'oh well, nothing to do... Success'

The same problem is true with the SFTP 'upload' task. It is asking for a file-mask which means potentially multiple files. Well, if I put in a file mask of "FileToUpload.csv" and the file exists, it will upload the file. If it does not exist, it does not ERROR due to it just being a 'filter' and not a Hard requirement for that file to exist.

Does that make sense? I need the SFTP task to CARE that the file is or is not there. And, for SFTP to note failure if there is an issue transferring the file. I consider NO file to be a failure but SFTP's 'Upload' task still connects successfully and is marked as a success even though Zero files were uploaded becuase its file mask showed 'zero' files to upload.

Is there a way to do what i'm asking?
bbusse
2011-08-08T18:50:57Z
I guess what i'm asking can be said in very simple terms like this, and maybe this needs to be a feature request.

1. SFTP - Upload a single file (not using a file mask). Reoccurring task requires this one file be sent successfully. Error if not found or other errors occur during the transfer.

2. File Copy - Copy a single fil (not using a file mask). Could be used for a reoccurring task that requires this file be copied. Error if not found or other errors during the copy. Would be beneficial to have the ability to specify the destination file name (including variables)


I have 2 ways i can accomplish what I want IF I can trap an error during the SFTP or the Copy step.

Method 1.
1. SFTP Specific file (required)
2. If successful, Move the file (using the rename option) to an .\Archive\ folder with a date (I know how do do this)

Method 2.
1. Copy the file to the .\Archive\ folder with a date using a variable (Unable to do this as Copy File task has no way to specify destination file name)
2. If the Copy was successfull, SFTP the Specific File. (trap errors)
Support
2011-08-08T18:51:14Z
Originally Posted by: bbusse 

I am not having any trouble Renaming a file or SFTP'ing a file. The problem i'm having is I have no way to have the 'copy file' operation Fail, if the file didn't exist as the copy operation does not care if it doesn't exist, its just using a wildcard (File mask) and if there's nothing to copy, it just says 'oh well, nothing to do... Success'



Never version of VisualCron can be set to fail when no files were copied.

Originally Posted by: bbusse 


The same problem is true with the SFTP 'upload' task. It is asking for a file-mask which means potentially multiple files. Well, if I put in a file mask of "FileToUpload.csv" and the file exists, it will upload the file. If it does not exist, it does not ERROR due to it just being a 'filter' and not a Hard requirement for that file to exist.



We don't have the same for SFTP but could add this in a future update.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2011-08-08T18:52:41Z
Regarding Upload for FTP you can use a Condition (of type file) to check if a certain file exists before uploading and then let it send an email if file is not found. Only limitation is that you need to know exactly which file to check for.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
bbusse
2011-08-08T18:57:08Z
Can I make a specific feature request for a 'Copy File' option to go along with the 'Copy Files' that would give the option of specifying a destination file name that can include variables?

Sometimes you want to 'Copy Files' using a wildcard or file mask and other times you just want to 'Copy File' becuase you have a specific file to copy and need to ensure it happens.

I would also like to be able to specify a 'required' file as there are many times I can think of where i'm going to SFTP the same exact file name every day and I need to ensure that it happens without error.

Brian
bbusse
2011-08-08T18:59:05Z
Originally Posted by: Support 

Regarding Upload for FTP you can use a Condition (of type file) to check if a certain file exists before uploading and then let it send an email if file is not found. Only limitation is that you need to know exactly which file to check for.




i thought of this as well, but i'm trying to figure out how to go about making these requirements part of the process itself vs having to have a globally available 'Condition' that clutters up the list. Its only going to be a condition for this exact process, never to be re-used, so i figure it would be better if it was handled as part of the SFTP process to check for the existance due to it being hard-coded which exact file to upload.

Thanks,
bbusse
2011-08-08T19:06:11Z
Originally Posted by: Support 

Never version of VisualCron can be set to fail when no files were copied.



I'm running 5.7.8 right now (latest i'm aware of). Where is this option at?

Brian
Support
2011-08-08T19:07:48Z
Look at the "On error" tab of the Task. By default it errors out if no files were copied.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top