4 Using the FTAM–FTP Gateway (Digital UNIX)
4.2 Using the FTAM–FTP Gateway from an Internet Host 6 Connecting to a Remote OSI Node
To access files on a remote OSI node using FTP, you first need to establish a connection to that node. Once you are connected to a node, you can use FTP commands to work with files and directories on that node.
You can connect to a node when starting the FTP session by using the same command sequence used to invoke the FTAM–FTP Gateway (described in Section 4.2.1). In this example, the gateway system (Internet node) isboston: % ftp boston Return
When the gateway prompts you for a user name, specify the alias of the FTAM system to which you want to connect and your login name on that system. Enter the information in this format:
alias::user
In this example, bostonis the Internet system where the gateway is installed and doe is the name of the user who initiated the FTP session;freundeis the FTAM alias representing the destination FTAM system; and smith is the login name of the user on the FTAM system.
Name (boston::doe): freunde::smith Return
Finally, enter the password at the Password prompt. The password does not appear on your screen, or echo, when you type it. For example:
Password (freunde::smith): secret Return
Here is an example of the complete connection process. The gateway system is
boston, the target FTAM system isfreunde, the user issmith, and the password issecret.
% ftp boston Return
Connected to boston.
220 boston FTP server (Version 4.1 Fri Feb 15 19:42:25 EDT 1996) ready. Name (boston::doe): freunde::smith Return
Password (freunde::smith): secret Return
331 Password required for FTAM gateway access freunde::smith. 230 User smith logged in.
ftp>
4.2.7 Disconnecting from a Remote OSI Node
To end your connection to a remote OSI node, type the close or disconnect
command at theftp>prompt. For example: ftp> close Return
221 Goodbye. ftp>
Note that the closecommand does not end the FTP session. The Internet connection is still in effect, but the FTAM association is terminated.
4.2.8 Viewing Remote Directories
While connected to a remote OSI node, you can view different directories on that node, as follows:
To change the current remote directory, type the cd command followed by the name of the directory. Enter the complete path name of the remote directory in the syntax expected by the remote system. If you do not specify the directory name with the cdcommand, the system prompts you for one. For example:
4.2 Using the FTAM–FTP Gateway from an Internet Host
ftp> cd /usr/users/smith/memos Return 250 CWD command successful. ftp> or ftp> cd Return(remote-directory) /usr/user/smith/memos Return
250 CWD command successful. ftp>
To return to the home directory after accessing a subdirectory in FTP, specify the full path name and the correct directory syntax with thecdcommand. You should use the cdcommand to set your default directory when opening your connection. Doing so allows you to use thelsanddir commands without an argument. To display the names of the remote files and directories, type the ls command. For example:
ftp> ls /smith/memos/tasks Return
200 PORT command successful.
150 Opening data connection for /smith/memos/tasks (123.45.6). bc.txt
status.sdml tips.txt
226 TRANSFER COMPLETE.
54 bytes received in 0.83 seconds (0.064 Kbytes/s) ftp>
For an expanded display, type the dircommand. For example: ftp> dir tasks Return
200 PORT command successful.
150 Opening data connection for /smith/memos/tasks (123.45.6). FTAM-1 -rwx--- 29266 Mar 13 1996 bc.txt
FTAM-1 -rw--- 6534 Apr 19 1996 status.sdml FTAM-1 -rwx--- 7718 May 15 12:55 tips.txt 226 TRANSFER COMPLETE.
300 bytes received in 0.71 seconds (0.41 Kbytes/s) ftp>
4.2.9 Displaying Remote Files
To display a remote file, type the get command followed by the name of the remote file and a hyphen. For example:
ftp> get team.txt - Return
200 PORT command successful. 150 Opening data connection for
/smith/memos/team.txt (123.45.6)
This file lists all the reviewers for the book: Donna Geeta John Larry Michael Ravi Scott Tracy 226 Transfer complete. remote: team.txt
111 bytes received in 0.15 seconds (0.72 Kbytes/s) ftp>
4.2 Using the FTAM–FTP Gateway from an Internet Host
The hyphen indicates that you want the file displayed at the terminal. If you omit the hyphen, the system copies the remote file to your current working directory, without displaying anything.
Therecv command works exactly likeget.
4.2.10 Setting the File Transfer Type
You can transfer, or copy, ASCII and binary files using ftp commands. Set the FTAM–FTP Gateway file transfer type to ASCII when you transfer ASCII files (FTAM-1 files) and to binary (image mode) when you transfer binary files (FTAM-3 files). ASCII is the default.
You can set the file transfer type using the FTP commands shown in the following examples.
To set the file transfer type to ASCII, enter the asciicommand. For example: ftp> ascii Return
200 Type set to A. ftp>
To set the file transfer type to binary image mode, type thebinarycommand. For example:
ftp> binary Return
200 Type set to I. ftp>
To display the current settings of the FTP variables, use the statuscommand.
4.2.11 Copying Files Between Systems
When connected to a remote OSI node, you can copy files to and from that node. To copy a remote file, type either the get orrecv command, followed by the remote file name. If you want the local file to have a different name, also specify a local file name. The getandrecv commands are interchangeable.
The following examples illustrate the different ways you can copy files with FTP commands.
• In the following example of the recv command, a local file name is not specified, so ftpcreates a local file with the same name as the remote file: ftp> recv games.lis Return
200 PORT command successful. 150 Opening data connection for
/smith/memos/games.lis (123.45.6) 226 Transfer complete.
local: games.lis remote:games.lis
6010 bytes received in 0.8 seconds (7.3 Kbytes/s) ftp>
4.2 Using the FTAM–FTP Gateway from an Internet Host
ftp> get games.lis games Return
200 PORT command successful. 150 Opening data connection for
/smith/memos/games.lis (123.45.6) 226 Transfer complete.
local: games remote:games.lis
6010 bytes received in 0.41 seconds (14 Kbytes/s) ftp>
Note
If you use the get or recv command and type a hyphen instead of specifying a local file name for the file, the file is displayed on your terminal without being copied to the local system.
• To copy a local file to a remote file, type theput command, followed by the local file name and the remote file name (optional). For example:
ftp> put team.txt newteam.txt Return
200 PORT command successful. 150 Opening data connection for
/smith/memos/team.txt (123.45.6) 226 Transfer complete.
local: team.txt remote: newteam.txt
6010 bytes sent in 0.4 seconds (42 Kbytes/s) ftp>
• To copy a local file to the end of a remote file, type the appendcommand followed by the local file name and the remote file name. The following example appends the local fileteam.txtto the remote filescores: ftp> append team.txt scores Return
200 PORT command successful. 150 Opening data connection for
/smith/memos/scores (123.45.6) 226 Transfer complete.
local: team.txt remote: scores
9398 bytes sent in 0.59 seconds (16 Kbytes/s) ftp>
You cannot use theappendcommand to copy a remote file to the end of a local file.
• To delete a single remote file, type the deletecommand followed by the file name. For example:
ftp> delete team.txt Return
250 DELE command successful. ftp>
If you do not specify the file name after the deletecommand, the system prompts you for the file name. For example:
ftp> delete Return
(remote-file) team.txt Return
250 DELE command successful. ftp>