VanDyke Software

Automation Tip

Index

How To Use vsftp Batch Mode To Automate File Transfers

This tip shows how to use the batch mode of the vsftp command-line utility (included with VShell® server and SecureCRT®) to automate file transfers.

To use vsftp batch mode, you create a batch file that contains sftp commands. Then you invoke vsftp using the -b switch to load the commands from the file.

vsftp -b <filename> is a command-line option that instructs vsftp to use batch mode, loading commands from a file rather than interactive input. When -b is used, vsftp reads from the specified file, executes all commands in the file, and then exits after the last command.

The vsftp include <filename> command can be used to start reading commands from a batch file. It can be used from the interactive prompt, or from within a batch file. Once all the commands in the included file have been executed, vsftp resumes reading commands either from the interactive command line, or the next line in the batch file that executed the include <filename> command.

The include command can also be used within the SecureCRT SFTP tab.

The error {continue/exit/exit-all} command is useful in conjunction with the batch file commands since it allows you to specify one of three options for error handling:

  • continue – Ignores errors and continues. The exit code reflects the status of the last command executed
  • exit – Exits the current batch file
  • exit-all – On error, exits the current batch file, or exits if in batch mode

Example: This example shows how to use the error command in combination with the include command to automate sending a set of commands contained in a batch file to multiple hosts.
In this example, the batch file, DoMyStuff.txt is used to automate the processes contained in Download.txt so that the process can be performed on multiple hosts.

From the Windows command line, issue the following command:

vsftp -b DoMyStuff.txt

Example DoMyStuff.txt batch file
error exit
open host1
include Download.txt
close
open host2
include Download.txt
close

etc.

Download.txt
get file1
rm file1


You can take advantage of the --log <logFileName> command line option to capture a log of the commands issued in a log file. Used in combination with the -v command line option, debugging/troubleshooting information will also be logged to the specified file.

If you have any questions about using the vsftp commands, contact VanDyke Software Support.

VanDyke Software uses cookies to give you the best online experience. Before continuing to use this site, please confirm that you agree to our use of cookies. Please see our Cookie Usage for details.