How To Automate An SFTP File Transfer

Automated file transfers are usually done through scripts, but we have better solution. Learn how to automate SFTP file transfers online at JSCAPE!

  1. Blog

Automated SFTP file transfers are traditionally done through scripts, but there's a much easier way. In this tutorial, we'll show you how to automate SFTP file transfers without scripting a single line of code.

To accomplish this task, we'll be using JSCAPE MFT Server, a managed file transfer solution that simplifies business process automation through the use of triggers. Triggers are a comprehensive suite of automation-enabling tools presented in an intuitive graphical user interface so you don't have to work through a command line. Let's show you how it works.

Getting Started

Would you prefer to watch a video taking you through the steps of automating an SFTP transfer? You can play the video below. Otherwise, just continue reading.

For a more comprehensive discussion on triggers, refer to the online documentation. This tutorial will give you an overview of how triggers work.

I've already logged into the JSCAPE MFT Server administrative web interface, which has all the same functionality of an on-prem SFTP client, and have navigated to the Triggers module. For this example, I'm going to create a trigger that would listen to a specific file movement in my machine's local file system. Once it detects that specific file movement, it will respond by uploading that same file to a remote SSH FTP service.

Before I create that trigger, let me first show you the trigger responsible for moving the file in question.

automate sftp transfer

So, as you can see from this trigger's action parameters, the file name to be moved is 'azureblobdownloadfile.txt', and it's going to be moved from 'E:\downloads' to 'D:\testuserfiles'. The trigger we're about to create should only respond to a file movement that involves this particular file and these particular source and destination directories.

automate sftp transfer - 2

Let's create that trigger now. To create the trigger, just go to the Triggers module and click the Add button.

automate sftp transfer - 3

Give this trigger a name, say, 'automate sftp transfer of moved file'. After that, select the 'File Move' Event type. This is the type of event this trigger is supposed to respond to. Note that there are several other event types to choose from. Here's an example that let's a trigger run on a predefined schedule:

How To Copy Files From Azure Blob Storage To AWS S3

automate sftp transfer - 5

In a production environment, there will presumably be several file movements and we want this trigger to respond only to a specific file movement, so we need to specify a set of trigger conditions.

I'm going to build a trigger condition that will allow this trigger to respond only to those File Move events where:

  • The Source File is 'E:\downloads\azureblobdownloadfile.txt', and
  • The Destination File is 'D:\testuserfiles\azureblobdownloadfile.txt'

Recommended read: Introducing the New Trigger Conditions Expression Builder

Click Next once you're done building the trigger condition.

automate sftp transfer - 6

In the next screen, click the Add button and then select 'SFTP File Upload' from the action drop-down list.

automate sftp transfer - 7

In the action parameters dialog, start by specifying the hostname or IP address of the remote SFTP server where you want to upload the file in question.

automate sftp transfer - 8

Next, enter the login credentials of a valid user account on that remote SFTP server.

After that, specify the file path of the file you wish to upload. Because we used the File Move event type in this trigger, we can use the %DestinationFile% variable for this purpose. This variable already holds the complete file path of the file after it was moved to the local destination directory.

Lastly, specify the target directory in the remote SFTP server. I just want this file to be uploaded to the user account's root directory, so I'm just going to enter the forward slash (/) here.

automate sftp transfer - 9

Click OK and then drag an arrow from the Start output of the Workflow node to the Trading Partner Synchronization Action node.

Recommended read: Introducing the Redesigned Trigger Action Workflow

Click OK to finalize the trigger creation process.

automate sftp transfer - 10

automate sftp transfer - 11

That's it. Now you know how to configure your secure FTP server so that you can automate an SFTP transfer.


Get Your Free Trial

Would you like to try this yourself? JSCAPE MFT Server is platform-agnostic and can be installed on Microsoft Windows, Linux, Mac OS X and Solaris, and can handle any file transfer protocol as well as multiple protocols from a single server. Additionally, JSCAPE enables you to handle any file type, including batch files and XML. Download your free 7-day trial of JSCAPE MFT Server now.

Download JSCAPE MFT Server

Related Content

How To Auto Upload Files To A Server From A Local Directory

Install A Linux SFTP Server Via Command Line And Configure Via Web UI

How To Set Up Automated AS2 File Transfers

How To Set Up A HTTPS File Transfer: HTTPS File Sharing