Home > DEV, Infrastructure > how to script an FTP upload in a BAT file

how to script an FTP upload in a BAT file

In several projects you have the need to automate your deployment procedures… unfortunately often your code is hosted by an external provider that for security reasons give you the access only with FTP…

This code is perfect to automate the upload of your deployment package.

1) Create a Bat File with the following code and name it Upload.bat

@echo off
echo user FTPUserName> ftpcmd.dat
echo FTPPWD >> ftpcmd.dat
echo cd FolderName >>ftpcmd.dat
echo bin>> ftpcmd.dat
echo put %1>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat FTPserverURL
del ftpcmd.dat

as you can understand you have to put into your username and password and eventually the code to switch directory if you are going to upload something on the root…

2) call your bat file with the following syntax: upload.bat testFile.zip

Happy scripting to everybody Smile

Categories: DEV, Infrastructure Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: