Monitoring A Remote SFTP Server for Newly Added Files

Posted by John Carl Villanueva on Sun, Feb 14, 2021 @ 04:45 PM

[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:

  • AFTP
  • WebDAV
  • Amazon S3
  • SFTP
  • SMB
  • FTP
  • 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. 

 

directory_monitor_sftp_server

 

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.

 

monitoring a remote sftp server for newly added files - 01

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:

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.

 

monitoring a remote sftp server for newly added files - 02

 

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.

 

monitoring a remote sftp server for newly added files - 03

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.

 

monitoring a remote sftp server for newly added files - 04

 

You should then see your newly created directory monitor on the screen.

 

monitoring a remote sftp server for newly added files - 05

 

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.

 

monitoring a remote sftp server for newly added files - 06

 

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.

 

monitoring a remote sftp server for newly added files - 07

 

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:

Introducing the New Trigger Conditions Expression Builder

Click Next to proceed.

 

monitoring a remote sftp server for newly added files - 08

 

It's now time to add the trigger action that would download the files from the SFTP server. Click the Add button.

 

monitoring a remote sftp server for newly added files - 09

 

And then select the Trading Partner File Download trigger action. Click OK.

 

monitoring a remote sftp server for newly added files - 10

 

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. 

 

monitoring a remote sftp server for newly added files - 11

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:

Introducing the Redesigned Trigger Action Workflow

 

monitoring a remote sftp server for newly added files - 12

 

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. 

 

monitoring a remote sftp server for newly added files - 13

 

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.

Download JSCAPE MFT Server

We'd love to engage with you on social media. Do connect with us ...

 

Topics: JSCAPE MFT Server, Managed File Transfer, Business Process Automation, Tutorials, SFTP, Triggers