Back   docs > tech help > ftp how to
     
   
     
    This document is a quick reference on how to use FTP (File Transfer Protocol) to transfer
files between 2 computers.  Although there are numerous Windows based FTP programs,
there are times when using the command line is more efficient.


For Windows operating systems


FTP is a TCP/IP program used to transfer files between 2 computers.
FTP requires your PC to be running the TCP/IP protocol.
The computer you want to interact with must be running the FTP Server Service
(or FTP daemon in Unix terms)
<enter> in this document means press the enter key
   

1. Start the ftp service by opening a DOS window or command prompt, and typing:

ftp <enter>.
ftp> this is the prompt you will see to let you know you started the ftp program.

For a list of ftp commands, at the ftp prompt, type help.
ftp>help <enter>
For help with individual commands, type help command (where command is the actual command)
ftp>help mput <enter>


2. Type status <enter> to see what options are set for this ftp session.

3. To open an FTP session with a computer running the FTP server service, use 
    the open command.


open ftp.server_name <enter>
ftp>open ftp.microsoft.com <enter>


4. You will be prompted for a user name, then a password:

Public ftp servers allow anonymous logins.  For these servers, the default user name is
anonymous, and the default password is your email address.

user:anonymous (use this name if the ftp server allows anonymous logins... most do.)

password:anything@anything.net (this is a formality, you can put any email name you want.
Some ftp servers will also let you just press the <enter> key for the password.)

*** If you have an account set up on the server, then use the user name and 
       password assigned to you.


5. Use the dir command to list the directories on the FTP server:

ftp>dir <enter>

You can also use the ls command:

ftp>ls <enter>

6. Use the cd command to change directories (works the same as it does in DOS):

ftp>cd products<enter> - changes to the products subdirectory

You can use cd. , cd.. and so on to move back, but use cd/ (forward slash) to go to the root.
Also, when using the cd command, put a space after cd, then .. or . or /


7. To download a file from a ftp server:

a. change to the directory on your PC where you want the file to go by using the 
    lcd command (local change directory).

b. change to the directory on the ftp server where the file you want to download is located.
c. then use the get or recv command (they both do the same thing).
    ***for multiple files use the mget command.


a. ftp>lcd c:\mydir <enter>
b. ftp>cd myftpdir <enter>
c. ftp>get dirmap.htm <enter>
    ftp>recv dirmap.txt <enter>


* Note:
There are two file transfer types with FTP.
The default file transfer type is ASCII.

In ASCII mode (text mode), data is transferred in such a way as to make it understandable on the
destination machine. ASCII mode "translates" the information so that the meaning of the data is
preserved. For example, if a file is transferred from a Macintosh to an IBM PC in ASCII mode,
the bit-sequence of the copy would not be identical to the original, as is the case with binary.
However, the data would be decipherable by the destination machine.

ASCII is used for .txt, .htm, .html files and email messages.

In Binary mode, data is transferred so that the original and the copy are bit-by-bit identical,
regardless of the compatibility of the two machines engaged in the ftp connection. If a file is 
transferred from a Macintosh to an IBM PC in Binary, the file on the IBM will be identical to the
file on the Mac, regardless of whether or not the IBM PC is able to decipher it.

Binary
file transfer is used for .exe, .com, .zip, .tar, .gif, .jpg, .doc, .xls files

If you are downloading a Binary file, type binary at the ftp> prompt first
to change the file transfer type to Binary:

ftp>binary <enter>
ftp>get chat.exe
ftp>get yn.com

To see what type of file transfer type you are using type, type <enter>
ftp>type <enter>
You can also use this command to change the file transfer type.
ftp>type binary <enter>
ftp>type ascii <enter>


To download multiple files use the mget command

ftp>mget *.txt <enter> - This will download all the .txt files in the current directory.
You will be prompted for each file before it is downloaded.

Type y <enter> for yes, or n <enter> for no, or just press <enter> for yes.

To disable prompting for multiple file puts or gets, type prompt at the ftp> prompt
before downloading the files.
The prompt command toggles prompting on and off.

ftp>prompt <enter>
ftp>mget *.txt <enter>
ftp>mget file1.txt, file2.txt, file3.txt  (you can enter multiple file names)
ftp>mget *.* <enter>
To abort a download or upload press <ctrl><break>


8. To copy a file to the ftp server:

a. change to the directory on your PC where the file is by using the 
    lcd command (local change directory).
b. change to the directory where you want the file to go on the ftp server.
c. then use the send or put command (they both do the same thing).
    ***for multiple files use the mput command.

a. ftp>lcd c:\mydir <enter>
b. ftp>cd myftpdir <enter>
c. ftp>send myfile.txt <enter>
    ftp>type binary <enter>
    ftp>put myfile.exe<enter>
    ftp>mput *.* <enter> - sends all the files in the current directory to the ftp server
    ftp>mput file1.txt, file2.txt, file3.txt  (you can enter multiple file names)


9. To disconnect from the ftp server:

ftp>disconnect <enter>
This will leave ftp running, but disconnect you from the server.
You can also use:
ftp> close <enter> to disconnect.

To end an ftp session, type quit or bye. This will disconnect you from the server, and
end the ftp session.
ftp>bye <enter>


MISC

The following commands are of interest:

ABOR abort a file transfer
BELL toggles a bell to ring after each file transfer is completed
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
MKDIR makes 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
RENAME renames a remote file
RMD remove a remote directory
RMDIR remove a remote directory
RNFR rename from
RNTO rename to
SITE site-specific commands
SIZE return the size of a file
STATUS typing this displays the options you have set for your session
STOR store a file on the remote host
TRACE off by default - displays the route of each packet
TYPE set transfer type
VERBOSE on by default - displays ftp response messages on your screen
USER send username


FTP codes and actions
The series code (the number) at the beginning of some lines of the FTP log describes the action
that took place between your computer and the server in the FTP process. The table below
describes these FTP codes and actions.  Note: not all FTP servers will use the same codes.

Code Description
100 Series Codes The requested action is being initiated, expect another reply before proceeding with a new command.
110 Restart marker reply.
120 Service ready in nnn minutes.
125 Data connection already open, transfer starting.
150 File status okay, about to open data connection.
200 Series Codes The requested action has been successfully completed.
200 Command okay.
202 Command not implemented, superfluous at this site.
211 System status, or system help reply.
212 Directory status.
213 File status.
214 Help message.
215 NAME system type. (Where NAME is an official system name from the list in the Assigned Numbers document.)
220 Service ready for new user.
221 Service closing control connection. Logged out if appropriate.
225 Data connection open; no transfer in progress.
226 Closing data connection. Requested file action successful (for example, file transfer or file abort).
227 Entering Passive Mode
230 User logged in, proceed.
250 Requested file action okay, completed.
257 "PATHNAME" created.
300 Series Codes The command has been accepted, but the requested action is being held in abeyance, pending receipt of further information.
331 User name okay, need password.
332 Need account for login.
350 Requested file action pending further information.
400 Series Codes The command was not accepted and the requested action did not take place, but the error condition is temporary and the action may be requested again.
401 This service is not accepting users now. User quota filled. Try again later.
421 Service not available, closing control connection. This may be a reply to any command if the service knows it must shut down.
425 Can't open data connection.
426 Connection closed; transfer aborted.
431 Log-in unsuccessful. User name and/or password invalid.
450 Requested file action not taken. File unavailable (e.g., file busy).
451 Requested action aborted: local error in processing.
452 Requested action not taken. Insufficient storage space in system.
453 File transfer incomplete. Insufficient storage space.
500 Series Codes The command was not accepted and the requested action did not take place.
500 Syntax error, command unrecognized. This may include errors such as command line too long.
501 Syntax error in parameters or arguments.
502 Command not implemented.
503 Bad sequence of commands.
504 Command not implemented for that parameter.
530 Not logged in.
532 Need account for storing files.
550 Requested action not taken. File unavailable (e.g., file not found, no access).
552 Requested file action aborted. Exceeded storage allocation (for current directory or dataset).
553 Requested action not taken. File name not allowed.

 

For more FTP info and commands see the Windows Resource Kit books.

Top

b/johnson:01