ftp


ftp

Transfers files to or from a computer running the FTP Server service.

Syntax

 ftp [-v] [-n] [-i] [-d] [-g] [-s:   filename   ] [-a] [-w:   windowsize   ] [   hostname   ] 

Options

-a

Uses any local interface for the endpoint of the FTP data connection. (The FTP data connection is used to transfer files and is different from the FTP control connection, which sends FTP commands between the client and server.)

-d

Enables debugging mode, which displays all FTP commands sent between the client and server.

-g

Disables globbing (filename expansion) so that wildcards can be used within local paths and filenames without being interpreted by the shell.

-i

Disables interactive prompting when multiple files are being transferred.

-n

Disables autologon to establish a control connection with the remote host but nothing else.

-s:filename

Executes a series of FTP commands stored in a text file as a batch job.

-w:windowsize

Specifies the amount of data that can be transferred before requiring that the receiving end issue a confirmation. The default transfer buffer size is 4,096 bytes.

-v

Disables showing responses of remote FTP connections.

hostname

Identifies the computer name (DNS or NetBIOS name ) or IP address of the remote computer you want to connect to using FTP (this must be the last parameter on the line).

Commands

You can select from a whole separate set of FTP-specific commands when you run ftp in interactive mode. Here are some of the more commonly used:

!

Escapes from an interactive FTP session to the command shell cmd.exe in order to execute the command, then returns to the FTP session.

ascii

Sets file transfer type to ASCII for transferring text files. ASCII is the default type, the other being binary.

binary

Sets file transfer type to binary for transferring binary files such as image files and Word documents.

bye, close, or quit

Terminates an FTP session with the remote server and exits the FTP shell.

cd remotedirectory

Changes to the specified directory on the remote server.

delete remotefilename

Deletes the file from the current directory on the remote server.

dir [remotedirectory] [localfilename]

Displays a directory listing of the specified remote directory (or the current remote directory if none is specified). If a filename is specified, the listing is saved with this name on the local machine instead of being displayed.

disconnect

Terminates an FTP session with the remote server, but stays within the FTP shell.

get remotefilename [localfilename]

Transfers the specified file from the remote server to the local machine, renaming it as well if localfilename is specified.

hash

Displays one hash character ( # ) each time 2,048 bytes are transferred (useful for displaying the progress when downloading large files).

help [ command ]

Lists the available FTP commands or displays a short description of the specified command.

lcd localdirectory

Changes to the specified directory on the local computer.

ls [remotedirectory] [localfilename]

Same as dir earlier in this list.

mget remotefilenames

Gets multiple files (see get earlier in this list).

mput localfilenames

Puts multiple files (see put later in this list).

open hostname [port]

Opens an FTP connection to the specified remote computer. hostname can be a computer name (DNS or NetBIOS name depending on the network) or IP address. port is required only if the remote server is listening on a different TCP port than the standard FTP port, which is 21.

prompt

Toggles prompting for confirmation by user (default is on).

put localfilename [remotefilename]

Transfers the specified file from the local machine to the remote server, renaming it as well if remotefilename is specified.

pwd

Displays the name of the current directory on the remote server.

remotehelp [ command ]

Displays a list of FTP commands understood by the remote server or describes a particular command.

user username

Logs on to the remote server as username and then prompts for a password.

Examples

Run FTP in interactive mode:

 C:\>  ftp  ftp> 

Open a session with an FTP server:

 ftp>  open 172.16.11.104  Connected to 172.16.11.104. 220 test Microsoft FTP Service (Version 5.0). 

Log on to the server as anonymous:

 User (172.16.11.104:(none)):  anonymous  331 Anonymous access allowed, send identity (e-mail name) as password. Password:  ********  230 Anonymous user logged in. 

Display the current directory on the server:

 ftp>  pwd  257 "/" is current directory. 

List the contents of the current directory on the server:

 ftp>  ls  200 PORT command successful. 150 Opening ASCII mode data connection for file list. hello.txt 226 Transfer complete. ftp: 11 bytes received in 0.04Seconds 0.28Kbytes/sec. 

Download the file hello.txt from the server to the client:

 ftp>  get hello.txt  200 PORT command successful. 150 Opening ASCII mode data connection for hello.txt(12 bytes). 226 Transfer complete. ftp: 12 bytes received in 0.00Seconds 12000.00Kbytes/sec. 

Escape from the FTP shell momentarily and run the command type C:\hello . txt on the client, which should display the contents of the text file if it's successfully downloaded from the server:

 ftp>  !type C:\hello.txt  Hello there!ftp> 

Note that the file contains the line of text "Hello there!"

Close the connection with the server and terminate the interactive FTP session:

 ftp>  quit  221 C:\> 

Notes

  • The ftp command is a client, as opposed to an FTP service or daemon, which resides on the server.

  • WS2003 includes an FTP Server service as part of its Internet Information Services (IIS). By default, the home or root directory of this service is mapped to the directory C:\Inetpub\ftproot on the server.

  • FTP is inherently insecure because it transmits passwords in clear text.

To use ftp in batch mode, do the following:

  1. Go through an interactive FTP session, and copy it to a text editor such as Notepad.

  2. Edit out the responses, leaving only the commands.

  3. Use the -s switch to run the batch file with ftp .

See Also

TCP/IP



Windows Server 2003 in a Nutshell
Windows Server 2003 in a Nutshell
ISBN: 0596004044
EAN: 2147483647
Year: 2003
Pages: 415
Authors: Mitch Tulloch

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net