Published on 23 Jun 2021
WinSCP is a popular Windows file transfer client. One of the reasons for its popularity is the flexibility and power of its scripting and automation capabilities.
When you install WinSCP, two executables get added to your computer – WinSCP.exe, which presents the familiar windowed interface for interactive transfers, and WinSCP.com, the command-line client.
It’s worth your time to check out WinSCP’s guide for creating automation using WinSCP.com, including useful example scripts.
This document won’t cover how to use WinSCP.com for scripting. Instead, we’ll discuss some things to keep in mind as you create your own automation scripts: logs, SSH keys, and planning.
The WinSCP.com command-line client can automatically create log files. Logs are invaluable when something goes wrong – you’ll see exactly which command failed and what error messages were included. If you know when the script fails, that helps point you at what to fix.
WinSCP.com allows you to control the name and format of your log files. You can also automatically configure log rotation by setting the maximum log size along with the maximum number of archive logs to keep. See more details about how to do this at https://winscp.net/eng/docs/commandline#logging
For SFTP connections, you can choose to connect to ExaVault with an SSH key. This type of connection is advantageous when you’ve created a script to automate your transfers. Instead of putting your password in your script, you can instead provide an SSH key.
ExaVault provides an easy-to-use interface for creating SSH keys and assigning them to specific users. Check out our documentation at https://www.exavault.com/docs/account/04-users/04-ssh-keys
Sometimes, your script will fail for unexpected reasons. Here are some possible scenarios:
These are just a few problems that can prevent your FTP automation from finishing successfully. If you are clever, you may find others. It’s not a question of if your script will fail, but what you will do when that happens.
Make a plan for detecting failures. How will you know something went wrong with your automation (preferably before your customers or vendors see any impact)?
Once you’re aware that your transfers didn’t complete the way you expected or how you expected, you should also plan for how you will recover.
WinSCP is a powerful and popular tool for automating file transfers. Combining smart usage of log files and SSH keys with a detailed plan can make the difference between an automation that saves you time and a frustrating emergency.