SFTP Manual

How does it work?
	SFTP opens the configuration file that you specify on the command line and
starts processing commands in order.  This means the commands have to be numbered in
the order in which they need to be processed.  SFTP continues to process commands
until a failure occurs or the last command is read.  The configuration file that
the commands are in is nothing more that a Windows ini file.  Commands are numbered
FTPCommand1=, FTPCommand2=, FTPCommand3=, etc.  The script command must follow the =
sign of each entry.

Script Commands:

****
CONN <FTP site name>:<remote port>
	This command specifies what FTP site to connect to.  If you place a :
at the end of the site name and specify a remote port it will override the
default port of 21.
	Example:
FTPCommand1=CONN ftp.testsite.com
or
FTPCommand1=CONN ftp.testsite.com:34

****
USER
	This command specifies what username to log in as.
	Example:
FTPCommand2=USER anonymous
or
FTPCommand2=USER testuser

****
PASS
	This command specifies the password for the username you just specified.
If you specify PASS without a password the program will prompt for it at run time.
It is also worth mentioning that if you are calling SFTP from your own program
you could prompt the user for the password and then edit the script from within
your program before you execute SFTP.
	Example:
FTPCommand3=PASS test@test.com
or
FTPCommand3=PASS

****
TYPE
	This command tells the remote FTP site that all transfers should be
done in binary mode.  This command is required before any uploads and downloads
can take place.  If you connect to multiple sites in one script you must include
the TYPE command before any transfers from each of the sites.  Only one example 
is given because the command can not be modified, it must be specified as you see 
it in the example(don't forget the I).
	Example:
FTPCommand4=TYPE I

****
PORT
	This command tells SFTP to establish a port command and prepare for a
transfer.  This command must preceed each and every individual upload or download and
must be specified exactly as presented below.
	Example:
FTPCommand5=PORT

****
RETR
	This command specifies what file to download and what to call it on the 
local machine.  This parameter starts downloading a file and storing it with the
filename that you specify.  The first part is the full path and filename to the
file on the remote FTP server.  The second part is the full path and filename to
the file on the local machine that will be created as a result of this download.
	Example:
FTPCommand6=RETR /pub/testdir/tesfile.zip c:\temp\testfile.zip
or
FTPCommand6=RETR /pub/tesfile.zip c:\temp\newfile.zip

****
STOR
	This command specifies what file to upload and what to call it on the 
remote FTP server.  This parameter starts uploading a file and storing it with the
filename that you specify.  The first part is the full path and filename to the new
file on the remote FTP server.  The second part is the full path and filename to
the file on the local machine that will be uploaded to the FTP server.
	Example:
FTPCommand8=STOR /incoming/testfile.zip c:\temp\testfile.zip
or
FTPCommand8=STOR /incoming/newfile.zip c:\temp\testfile.zip

****
EXEC
	This command executes a program.  When this command is processed,
SFTP reads in whatever you specify and attempts to execute is as a Windows
program.  This command was added so that you may know when the script is
finished or when a particular transfer was finished.  Keep in mind that if
a failure occurs before this command SFTP will never process it(See the section
on Logging below).
	Example:
FTPCommand9=EXEC notepad
or
FTPCommand9=EXEC calc

****
QUIT
	This command closes your connection to an FTP server.  This should always
follow the last transfer you execute for each FTP server you connect to.  The command
has no options and should be specified as you see it below.
	Example:
FTPCommand10=QUIT


Logging:
	When a command is first processed SFTP creates an entry in your
configuration file under the [Status] heading.  This entry is CommandStatus1=, this
entry directly corresponds to the command number being processed and is immediatley 
set to Fail.  If SFTP completes the command succesfully it will go back and set
it to Success.  After a script has been succesfully executed once you will notice
that the [Status] section has a CommandStatusx= entry for each command with
the word Success following it.  If these entries are left in the configuration file
(which is fine), when SFTP is executed with this same script it will set each and
every CommandStatusx= entry to Fail before it does anything else.  Then, as the script
is processed SFTP will set them to Success if the command succeeds.  One additional feature
has been added to the Status section to make things a little easier on you.  When SFTP
starts up it will create an entry under Status called ExitCode and will set it to be blank.
If this entry already exist it will simply set it to be blank.  If any error occurs during
the execution of the script and SFTP has to exit it will set this field to Failure otherwise
when SFTP reaches the end of the script and exits normally it will set this entry to Success.
With all of that in mind it is possible that your program can call SFTP with a script and
simply monitor the Status/ExitCode entry for Success or Failure and if it reads Failure
you can process the CommandStatusx= to see how far it got.  You may find it better to set the
Status/ExitCode entry to blank from your program so that there is no delay between your
program monitoring it and SFTP initializing it to be blank.  One last bit of information
on logging.  Do not use a .log extension on your configuration file.  SFTP takes the name
of your configuration file, strips off the extension and appends .log to it.  This file
contains everything read off of the control socket.  In other words, it contains the FTP
servers half of the conversation with you.  Take a look at it, you may find it usefull, and 
it will probably look familiar to a novice FTP user.

Support:
	Please do not hesitate to contact me with questions or comments.  I can be reached
by email at marks@leaseplan.com	