The following information is provided as a reference for the File Transfer Protocol (FTP) commands. This document describes a typical process for an interactive and automated, batch FTP session running on a PC with Windows/2000 and connecting to a UNIX system. This process may vary slightly depending on the hardware and software configurations of the local and remote systems.
To start an FTP interactive session type "ftp" from a DOS Command window.
C:\> ftp
The DOS prompt should be replaced with the FTP prompt. The FTP program is now running on the local system. A connection (or session) to a remote system has not been established.
The help command or ? (
question mark) may be executed without being attached to a remote system and will do a print (usually to the screen) of the FTP commands. The following is a typical result of the help command running on a PC with Windows.
ftp> help
Commands may be abbreviated. Commands are:
! delete literal prompt send
? debug ls put status
append dir mdelete pwd trace
ascii disconnect mdir quit type
bell get mget quote user
binary glob mkdir recv verbose
bye hash mls remotehelp
cd help mput rename
close lcd open rmdir
ftp>
The following commands will establish a connection (or session) by doing a logon between the local FTP program and a remote system.
ftp> open domain.name
Connected to domain.name
220 antigonous FTP server ready.
User (domain.name:(none)): User-Name
331 Password required for user-name
Password: password
230 User user-name logged in.
ftp>
The following command will change the directory on the remote system.
ftp> cd /web
250 CWD command successful.
ftp>
The following command will find out the pathname of the current directory on the remote system and display the information.
ftp> pwd
257 "/web" is the current directory.
ftp>
The following command will set the file transfer mode to ASCII (this is the default and transmits seven bits per byte).
ftp> ascii
200 Type set to A.
ftp>
The following command will copy a file from the local system to the remote system.
ftp> put d:\simoweb1\filename.txt
200 PORT command successful.
Opening ASCII mode data connection for filename.txt
226 Transfer complete
ftp>
The following command will set the file transfer mode to binary (the binary mode transfers all eight bits per byte and must be used to transfer non-ASCII files).
ftp> binary
200 Type set to I.
ftp>
The following command will copy a file from the local system to the remote system.
ftp> put d:\simoweb1\filename.zip
200 PORT command successful.
Opening BINARY mode data connection for filename.zip
226 Transfer complete
ftp>
The following command will exit the FTP environment (
same as "bye").
ftp> quit
221 Goodbye.
When the preceding command is finished the DOS prompt will be displayed.
C:\>
The preceding is a typical process for an interactive FTP session running on a PC with Windows/2000 and connecting to a UNIX system. This process may vary slightly depending on the hardware and software configurations of the local and remote systems.
The following batch file
(UPWIP001.BAT) will start an FTP session and pass the name of a text file
(UPWIP001.TXT) to the FTP program. This text file will be processed by the FTP program and each of the statements in the text file will be processed in the sequence they appear.
@echo OFF
echo * *******************************************************************
echo * This program is provided by: *
echo * SimoTime Enterprises, LLC *
echo * (C) Copyright 1987-2001 All Rights Reserved *
echo * Web Site URL: http://www.simotime.com *
echo * e-mail: helpdesk@simotime.com *
echo * *******************************************************************
echo *
echo * This batch and text file illustrate the use of FTP to upload an
echo * ASCII file and an EBCDIC or Binary file. The UPWIP001.BAT file
echo * references UPWIP001.TXT that contains...
echo *
echo * user
echo * password
echo * cd /web
echo * pwd
echo * ascii
echo * put d:\simoweb1\cbltxn01.htm
echo * binary
echo * put d:\simoweb1\cbltxn01.zip
echo * quit
echo *
ftp -s:upwip001.txt www.simotime.com
The following is a listing of the contents of the text file
(UPWIP001.TXT).
user
password
cd /web
pwd
ascii
put d:\simoweb1\cbltxn01.htm
binary
put d:\simoweb1\cbltxn01.zip
quit
The following is a summary of the commonly used FTP Commands.
Command | Description |
! | Preceding a command with the exclamation point will cause the command to execute on the local system instead of the remote system. |
? | Request assistance or information about the FTP commands. This command does not require a connection to a remote system. |
ascii | Set the file transfer mode to ASCII (Note: this is the default and transmits seven bits per byte). |
bell | Turns bell mode on / off. This command does not require a connection to a remote system. |
binary | Set the file transfer mode to binary (Note: the binary mode transfers all eight bits per byte and must be used to transfer non-ASCII files). |
bye | Exit the FTP environment (same as quit). This command does not require a connection to a remote system. |
cd | Change directory on the remote system. |
close | Terminate a session with another system. |
debug | Sets debugging on/off. This command does not require a connection to a remote system. |
delete | Delete (remove) a file in the current remote directory (same as rm in UNIX). |
dir | Lists the contents of the remote directory.The asterisk (*) and the question mark (?) may be used as wild cards. For example:
dir b* | This will display all entries that start with the letter "b". For example, the following will be displayed.
bet, ben, bingo, born, boon, bipartisan, bandit, boy |
dir b*n* | This will display all entries that start with the letter "b" and have the letter "n" somewhere after the letter "b". For example, the following will be displayed.
ben, bingo, born, boon, bipartisan, bandit
The following will not be displayed.
bet, boy |
dir b?n | This will display all entries that start with the letter "b", have the letter "n" in the 3rd position and have a three character name. For example, the following will be displayed.
ben
The following will not be displayed.
bet, bingo, born, boon, bipartisan, bandit, boy |
dir b?n* | This will display all entries that start with the letter "b" and have the letter "n" in the 3rd position. For example, the following will be displayed.
ben, bingo, bandit
The following will not be displayed.
bet, born, boon, bipartisan, boy |
|
get | Copy a file from the remote system to the local system.
get filename-1 | Copy (or replace) filename-1 from the current remote directory to a file with the same name in the current local directory. |
get filename-1 filename-2 | Copy (or replace) filename-1 from the current remote directory to filename-2 in the current local directory. |
|
help | Request a list of all available FTP commands. This command does not require a connection to a remote system. |
lcd | Change directory on your local system (same as CD in UNIX). |
ls | List the names of the files in the current remote directory. |
mget | Copy multiple files from the remote system to the local system. (Note: You will be prompted for a "y/n" response before copying each file).
mget * | Copies all the files in the current remote directory to the current local directory, using the same filenames. Note the use of the asterisk (*) as a wild card character. |
|
mkdir | Make a new directory within the current remote directory. |
mput | Copy multiple files from the local system to the remote system. (Note: You will be prompted for a "y/n" response before copying each file). |
open | Open a connection with another system. |
put | Copy a file from the local system to the remote system. |
pwd | Find out the pathname of the current directory on the remote system. |
quit | Exit the FTP environment (same as "bye"). This command does not require a connection to a remote system. |
rmdir | Remove (delete) a directory in the current remote directory. |
trace | Toggles packet tracing. This command does not require a connection to a remote system. |
The following are additional commands that are used when tranferring files between an IBM Mainframe and a Windows or UNIX client swystem. Also, the following includes commands required when working with files containing variable length records.
user
password
CD ..
PWD
VERBOSE
BINARY
LITERAL SITE RDW LRECL=80 RECFM=FB TRACKS PRIMARY=10 SECONDARY=5
PUT c:\SimoDemo\TestLib1\DataFtp1\CARDFILE.DAT SIMOTIME.DATA.CARDFILE
QUIT
No comments:
Post a Comment