Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
sulasno
- Posts: 2
- Joined: 26 Jul 2011 10:38
#1
Post
by sulasno » 26 Jul 2011 10:53
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
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 26 Jul 2011 12:12
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
-
sulasno
- Posts: 2
- Joined: 26 Jul 2011 10:38
#3
Post
by sulasno » 26 Jul 2011 12:21
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
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#4
Post
by aGerman » 26 Jul 2011 12:31
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