Page 1 of 1

How to create a batch file to upload to a ftp server

Posted: 26 Jul 2011 10:53
by sulasno
How to create a batch file to upload to a ftp server?

at a prompt I have to input the following

Code: Select all

ftp
open ftp.domain.com
username
password
put "E:\chrome.png"
close
quit


tia

Re: How to create a batch file to upload to a ftp server

Posted: 26 Jul 2011 12:12
by aGerman
FTP is a console tool, but normally you can't append the FTP commands in a batch file directly.
There is a simple trick to do it nevertheless.

Code: Select all

@ftp -i -s:"%~f0"&goto :eof
open ftp.domain.com
username
password
put "E:\chrome.png"
close
quit

The first line is the only batch code. Because that line is no FTP command it causes an error but this doesn't matter ... give it a try.
Also, have a look at DosTips FTP Batch Script.

Regards
aGerman

Re: How to create a batch file to upload to a ftp server

Posted: 26 Jul 2011 12:21
by sulasno
using your code, the console opens and simply closes

looking at Classic FTP - Executing a FTP script

does it means that I create a batch file with only

FTP -v -i -s:ftpscript.txt

and ftpscript.txt contains the code

Re: How to create a batch file to upload to a ftp server

Posted: 26 Jul 2011 12:31
by aGerman
sulasno wrote:FTP -v -i -s:ftpscript.txt

Similarly. It uses the own batch code instead of ftpscript.txt.
%~f0 expands to the path and file name of your batch file.

Regards
aGerman