Page 1 of 1

Automating FTP.

Posted: 23 Feb 2009 06:26
by samuel_inba
Hi,
I am new to Dos programming ...
can any one provide me a test code which will automate the process of FTP (putting file to a server).

The script needs to get User name/ pwd and the source file name and destination file name.

if there are multiple files that need to be put to the server the above process should go in a loop untill the user wants to quit.

Pls hlp.

Thanks in advance.

Posted: 23 Feb 2009 10:29
by RElliott63
You could start with something like...


Code: Select all


Cls
Set /P User=Enter UserID:
Set /P Pwd=Enter Password:

Echo Open xx.xx.xx.xx         > %Temp%\FTPScript
Echo User %User% %Pwd%       >> %Temp%\FTPScript
Echo CD \DestFolder          >> %Temp%\FTPScript
Echo LCD \SourceFolder       >> %Temp%\FTPScript

:GetAnotherFile

  Set /P SName=Enter SOURCE File Name:
  If /I [%SName%] EQU [Quit] Goto FTPJob

  Set /P TName=Enter TARGET File Name:

  Echo Put %SName% %TName%   >> %Temp%\FTPScript
  Set "SName="
  Set "TName="
  Goto GetAnotherFile

:FTPJob

ftp -n -s:%Temp%\FTPScript  > %Temp%\FTPJob.Log


You could then view the FTPJob.Log file to see if everything transferred without errors.

Posted: 04 Mar 2009 05:05
by samuel_inba
Hi,
Sorry for the delayed response. Thanks for you reply. It solved my issue.Thanks a Lot. :D