[Last updated February 2021] Most users of JSCAPE MFT Server are already familiar with directory monitors. You often use them to monitor local directories and UNC paths for newly added files. But did you know, in later versions, you could also use directory monitors to monitor remote directories? Let me show you how.
Brief review of directory monitors
For the uninitiated, the directory monitor module is one of the most widely used automation-enabling features of JSCAPE MFT Server. Usually combined with triggers, directory monitors often act as "initiators" of automated processes. They monitor a directory for certain events (a newly added file, a file deletion, a file change, and so on) which then sets off a trigger that in turns carries out an automated task, e.g. transfer a file to a remote server, move a file to a folder for archiving, send out an email notification, and so on.
For more information about directory monitors, you may read the online documentation or watch this video:
Monitoring directories on remote servers
As mentioned earlier, previous versions of MFT Server could only monitor local directories and UNC paths. But starting version 11 (yes, this feature has been around for some time now), directory monitors could already be used to monitor directories on remote servers. Some of the remote services whose directories MFT Server is able to monitor include:
- Amazon S3
- FTPS Implicit
- FTPS Explicit
- and others
One particular use case is to monitor a directory on a remote SFTP server for newly added files. Once a file arrives at the monitored directory, MFT Server could then automatically download that file(s) for local processing.
How to monitor a remote SFTP server for newly added files
Let me now show you how to implement that.
Prefer to watch a video version of showing how to monitor a remote SFTP server for newly added files instead? Play the video below. Otherwise, skip it.
1. Make sure you have an existing SFTP trading partner
To monitor a directory on a remote SFTP server, that server should be associated with a MFT Server Trading Partner object.
As we already have several online resources about trading partners, we invite you to review those if you don't know what trading partners are yet. Here are some links to get you started:
- Trading Partner documentation
- Video: Using Trading Partners
- Downloading Files Periodically From A Trading Partner
Once you have your trading partner ready, the next step would be to create a directory monitor to monitor you SFTP trading partner.
2. Create a directory monitor to monitor your SFTP trading partner
Go to the Directory Monitors module and click the Add button to add a new directory monitor.
Give the directory monitor a Name and select the trading partner in Step 1 from the Use trading partner drop-down list.
In the Directory field, you may specify the specific relative path of the directory you want to monitor. So, for example, you may enter something like /folder1/subfolder1 if that's the folder you want to monitor. I just entered '/' because I simply want to monitor the root folder of the user account associated with my trading partner.
As usual, you may also configure other settings like the Monitor interval, Latency period, and so on.
Lastly, because I want to monitor this remote directory for newly added files, I make sure the Monitor file add setting is checked.
Click OK to proceed.
You should then see your newly created directory monitor on the screen.
We now proceed to create the trigger that would download files from your SFTP trading partner.
2. Create a trigger to download files from your SFTP trading partner
Go to the Triggers module and then click the button.
Give the trigger a Name and then select the Directory Monitor File Added event type from the drop-down list. This will tell the trigger to listen to any file additions to any monitored directory.
Because we want this trigger to respond only to those directory monitor file added events that originate from the 'Dirmon for TP1-SFTP' directory monitor (which is the directory monitor that monitors our remote SFTP server), we specify that in Expression box like so:
MonitorName = "Dirmon for TP1-SFTP"
You may replace the text enclosed by the quotation marks with the name of your directory monitor.
To learn more about building expressions using the Expression Builder, read the post:
Click Next to proceed.
It's now time to add the trigger action that would download the files from the SFTP server. Click the Add button.
And then select the Trading Partner File Download trigger action. Click OK.
After that, you'll need to set the trigger action parameters.
First, select the trading partner in question from the Partner drop-down list.
Next, enter the %File% variable into the Remote File field. This variable contains the complete path of the file that was added into the directory of the remote SFTP server we are monitoring.
Lastly, we specify the local file into which this downloaded file will be stored. Because we just want to retain the file's original filename, we specify the Local File value like so:
C:\Downloads from TP1-SFTP\%Name%
Of course, you would have to replace C:\Downloads from TP1-SFTP\ with your own local directory.
After clicking OK, you'll be brought back to the Add Trigger screen, where you should see your newly created trigger action. Drag an arrow from the Start output of the Workflow node to the Execute input of the newly added trigger action node.
For more information about creating trigger action workflows, read the post:
Once you're done creating your trigger action workflow, click OK until you're back at the main screen, where you should see your newly created trigger.
That's it. Now you know how to configure MFT Server to monitor a remote SFTP server for newly added files.
Try this yourself
Would you like to try this yourself? Download the FREE, fully-functional Starter Edition of JSCAPE MFT Server now.
We'd love to engage with you on social media. Do connect with us ...