Upload File to FTP Server via Command Shell

How to FTP using Windows Command Prompt

Go to the Start Menu and Click Run…
kb-global-start-run

In the Run dialog box, type cmd and click OK

kb-global-cmd-300x148

The Windows Command Prompt will open. Type the following command to connect to your server:

ftp yourdomain.com

Where yourdomain.com is your domain or the FTP Server IP Address found in the HELM Control Panel under the FTP Account Details.

kb-cmdftplogin

Once you hit Enter it will attempt to connect to the server. If it is successful, you will be prompted for a Username and Password. Enter the FTP username and password information to login.

Once you have Logged in, you should see a line like ftp>

To list the Directory Contents, use the command dir

kb-cmdftplogindir-300x149

You have successfully connected to your server through FTP using Windows Command Prompt.

More FTP Commands:

ABOR – abort a file transfer
CWD – change working directory
DELE – delete a remote file
LIST – list remote files
MDTM – return the modification time of a file
MKD – make a remote directory
NLST – name list of remote directory
PASS – send password
PASV – enter passive mode
PORT – open a data port
PWD – print working directory
QUIT – terminate the connection
RETR – retrieve a remote file
RMD – remove a remote directory
RNFR – rename from
RNTO – rename to
SITE – site-specific commands
SIZE – return the size of a file
STOR – store a file on the remote host
TYPE – set transfer type
USER – send username

Automating File Uploads

Create a commands file (in my example it is named commands.txt).

Type the following in your commands.txt:

open FTP_ADDRESS
FTP_USERNAME
FTP_PASSWORD
put FILENAME

!del FILENAME
bye

Any commands starting with “!” will be executed on the local server rather than the remote server. Remove the line marked in Red if you would like to keep the files on the source server after the upload has been finished.

To execute these commands type in the windows command prompt:

ftp -s:commands.txt

This command will execute the script.

If you would like to automate the file upload, create a MS-DOS batch file with notepad ( extension needs to be .cmd or .bat) and save the above FTP command. You can now use this file to create scheduled tasks and run it at specific intervals.

To find out how to use VBScript instead, check out yesterday’s article on FTP File Uploads.

Advertisements

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