login about faq

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%20KB's gravatar image


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

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%20KB's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Dec 21 '10 at 19:46

Seen: 12,764 times

Last updated: Mar 01 '11 at 22:22

All user contributed content licensed under the cc-by-sa license.
Powered by OSQA.