FTP from command line

Starting the command-line FTP client
Click on the Windows “Start” button then select “Command Prompt.”
At the “C:\” prompt in the resulting dialogue box, type this command:

ftp

You can tell that ftp is ready for your commands when you see the prompt:
ftp>

At the ftp prompt, type the ftp “open” command and the name of the computer to which you wish to connect. For example, if you wanted to connect to valugi.ro, you would type this ftp command:

open valugi.ro

Press the ENTER key. Note: You will press the ENTER key after <
help

you will see a list of commands available to you.

# *!* – Runs the specified command on the local computer
# *?* – Displays descriptions for ftp commands
# *append* – Appends a local file to a file on the remote computer
# *ascii* – Sets the file transfer type to ASCII, the default
# *bell* – Toggles a bell to ring after each file transfer command is completed (default = OFF)
# *binary* – Sets the file transfer type to binary
# *bye* – Ends the FTP session and exits ftp
# *cd* – Changes the working directory on the remote computer
# *close* – Ends the FTP session and returns to the command interpreter
# *debug* – Toggles debugging (default = OFF)
# *delete* – Deletes a single file on a remote computer
# *dir* – Displays a list of a remote directory’s files and subdirectories
# *disconnect* – Disconnects from the remote computer, retaining the ftp prompt
# *get* – Copies a single remote file to the local computer
# *glob* – Toggles filename globbing (wildcard characters) (default = ON)
# *hash* – Toggles hash-sign (#) printing for each data block transferred (default = OFF)
# *help* – Displays descriptions for ftp commands
# *lcd* – Changes the working directory on the local computer
# *literal* – Sends arguments, verbatim, to the remote FTP server
# *ls* – Displays an abbreviated list of a remote directory’s files and subdirectories
# *mdelete* – Deletes one or more files on a remote computer
# *mdir* – Displays a list of a remote directory’s files and subdirectories
# *mget* – Copies one or more remote files to the local computer
# *mkdir* – Creates a remote directory
# *mls* – Displays an abbreviated list of a remote directory’s files and subdirectories
# *mput* – Copies one or more local files to the remote computer
# *open* – Connects to the specified FTP server
# *prompt* – Toggles prompting (default = ON)
# *put* – Copies a single local file to the remote computer
# *pwd* – Displays the current directory on the remote computer (literally, “print working directory”)
# *quit* – Ends the FTP session with the remote computer and exits ftp (same as “bye”)
# *quote* – Sends arguments, verbatim, to the remote FTP server (same as “literal”)
# *recv* – Copies a remote file to the local computer
# *remotehelp* – Displays help for remote commands
# *rename* – Renames remote files
# *rmdir* – Deletes a remote directory
# *send* – Copies a local file to the remote computer (same as “put”)
# *status* – Displays the current status of FTP connections
# *trace* – Toggles packet tracing (default = OFF)
# *type* – Sets or displays the file transfer type (default = ASCII)
# *user* – Specifes a user to the remote computer
# *verbose* – Toggles verbose mode (default = ON)

File Transfer

You need to let ftp know whether you are transfering ASCII text files (e.g., a text-only file or an HTML file) or a binary file (e.g., a file in proprietary or machine-readable format–a spreadsheet, word-processor file, graphics file, sound, or any other file you cannot edit with Notepad [Windows].

For files that contain only text or program source code, type this ftp command:
ascii

Commands details
For files that contain executable programs or files with formatting codes such as those produced by word processing, spreadsheet or graphics programs, type this ftp command
binary

You can use these two commands in the same session; for example, type “binary” before transfering a web site’s graphics, then type “ascii” before transfering a web site’s HTML files.

Change to the directories where the files are located and where you want to transfer files.

Use the lcd command to change directories on your local desktop computer. For example, if you have a directory called Webwork on your C:\ drive, type this ftp command:

lcd c:\Webwork

Note: If the directory name has a space in it, enclose the directory name in quotes. For example:

lcd c:\"Web Work"

Use the cd command to change directories on the remote computer. For example, if you are working on a web page in your public_html directory, type this ftp command:

cd public_html

Downloading Files
Transferring file(s) from the remote computer to your local computer:

Use either the get or mget commands to download files.

To download one file (e.g., valugi.html), use the ftp “get” command:

get valugi.html

If you have selected just one file to transfer, you can rename it at the same time by adding the new name to the “get” command:

get valugi.html new_elzo.html

To download multiple files, use the ftp “mget” command and a wildcard character. For example, to download all the HTML files whose names begin CSCC, you would type this ftp command:

mget CSCC*.html

Each time the ftp program transfers a file that matches the “wildname” you’ve specified with the mget command, you will be prompted to confirm the transfer:

mget CSCC01.html?

If you want to transfer the file, type y (yes) and press the ENTER key. If you want to skip over this file, type n (no) and press the ENTER key.

Uploading Files

Transferring file(s) from your local desktop computer to the remote host:
Use either the put or mput commands to upload files.

To upload one file (e.g., valugi.html), use the ftp “put” command:
put valugi.html

If you have selected just one file to transfer, you can rename it at the same time by adding the new name to the “put” command:
put valugi.html new_elzo.html

To upload multiple files, use the ftp “mput” command and a wildcard character. For example, to upload all the HTML files whose names begin valugi, you would type this ftp command:

mget valugi*.html

Each time the ftp program transfers a file that matches the “wildname” you’ve specified with the mput command, you will be prompted to confirm the transfer:

mput valugi01.html?

If you want to transfer the file, type y (yes) and press the ENTER key. If you want to skip over this file, type n (no) and press the ENTER key.

Closing FTP

To close the connection with the remote host, type this ftp command:
quit
More details about the ftp syntax you can find here.


About this entry