Could someone show an example on how to use sftpg3 in batch mode to automate a file transfer from a Windows host?
asked Dec 21 '10 at 19:46
SSH KB ♦
Following is an example of a simple file transfer setup from a Windows client using sftpg3 in batch mode.
Let's say that our User wants to transfer a file called c:\temp dir\myfile.txt to a server called "Ernie" immediately after logging in and then rename it as serverfile.txt. We'll create two files to automate this process, assuming we've already configured some form of non-interactive authentication.
The first file, sftp-commands.txt, contains the sftp commands which will put the file up on to Ernie.
Contents of sftp-commands.txt:
lcd "/c:/temp dir/" put myfile.txt rename myfile.txt serverfile.txt quit
Next, we'll need a second file, transfer.bat, which will call sftpg3 in batch mode, and tells sftpg3 to use the sftp-commands.txt file for sftp commands.
Contents of transfer.bat:
sftpg3.exe -B sftp-commands.txt User@Ernie
All that is needed to automate this on login is place transfer.bat in the user's Startup folder.
answered Dec 21 '10 at 19:50
SSH KB ♦