Automating Windows SCP scripts with WinSCP

Legacy FTP usage is being phased out and most of you will have to face newer company security policies to start using SCP to transfer your daily backups from one server to another. Luckily for the system administrators, this is easily done using WinSCP's command line console as this article will demonstrate.

The example code below connects to '' with account 'user' and password 'pass123', uploads a file and closes the session. For the sake of this article, let's call this example.ini:

# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
# Force binary mode transfer
option transfer binary
# Upload file to the local directory d:\
put examplefile.txt d:\
# Disconnect

You can then call this script through WinSCP console as follows:

winscp.exe /console /script=example.ini

No comments: