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:
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.
Here you can control cookies using the checkboxes below. Some cookies are essential for the use of our website and cannot be disabled. Others provide a convenience to the user and, if disabled, may reduce the ease of use of our site. Finally, some cookies provide anonymous analytic tracking data that help us provide the user with a richer browsing experience. You can elect to disable these cookies as well.