execute FTP commands from batch script

create two files named script.txt and batch.bat

script.txt code:

open ftp.server.com
username
password
cd folderpath/newfolder
get file1.xml
close
bye

and batch.bat code

ftp -v -i -s:script.txt
echo done!


thats it now execute the batch file which will execute ftp commands from file script.txt

OR

Another way is to directly execute ftp commands from .bat file no need of 2nd file i.e no need of script.txt

create only one file process.bat

code:

@ftp -i -s:"%~f0"&GOTO:EOF
open ftp.server.com
username
password
cd folderpath/newfolder
get file1.xml
close
bye

here %~f0 is the current file, so the first line of the bat calls ftp, and
passes this same file as the -s: parameter,
when ftp ends, the goto:eof command skips the rest of the bat file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s