FTP - the File Transfer Protocol - allows you to connect to a remote host and perform the following actions: o Transfer files between your local host and the connected remote host o Append local files to remote host files o Delete and rename files on the remote host o Create, delete, and rename directories on the remote host o View the contents of directories and files on the remote host FTP also allows you to set and display the default working directory on the remote host as well as on your local host, and to customize FTP command processing. You can also use RCP to copy files. For more information on RCP, see Remote_Commands. To use the Secure Shell (SSH) for file transfers, refer to the HP TCP/IP Services for OpenVMS Guide to SSH. To use FTP, you need the following: o A user account on the OpenVMS system with access to TCP/IP Services for OpenVMS o One of the following: - A user account on the remote FTP host - Access to the remote host's ANONYMOUS user account
1 – Command Summary
To use FTP, enter the commands summarized below. For complete descriptions (including UNIX equivalents) of each command, type the following command: $ FTP FTP>HELP Command Description Starting and Exiting (At the DCL Prompt) FTP Invokes FTP. FTP remote_host Invokes FTP and establishes a connection to a remote host. Starting and Exiting (At the FTP> Prompt) CONNECT Establishes a connection to a remote host. DISCONNECT Closes the connection with the remote host. EXIT Closes the connection with the remote host Ctrl/Z and exits FTP. Sending Commands to the Remote Host APPEND Appends a local file to a remote file. CREATE/DIRECTORY Creates a remote directory. DELETE Deletes remote files. DIRECTORY Lists remote file names and related information. GET Copies files from the remote host to the local host. LOGIN Logs you in to a remote host. PUT Copies files from the local host to the remote host. RENAME Renames remote files. SET DEFAULT Sets the remote working directory or the local working directory. SHOW DEFAULT Displays the name of the current working directory. VIEW Displays the contents of a file on the current output device. Suspending FTP to Return to DCL Prompt SPAWN Suspends FTP to create a subprocess at the local DCL prompt. Customizing Your Session's Environment DISABLE LOG Disables the display of all the protocol commands sent to the remote host. DISABLE PARSE Disables the expansion of file names. DISABLE Disables the sending of the FTP protocol PORT_COMMAND PORT command. DISABLE REPLY Disables the display of all responses from the remote host. DISABLE Disables the display of # for each 1K bytes TRANSFER_VERIFICATION of data transferred. DISABLE Disables the special OpenVMS-to-OpenVMS VMS_PLUS transfer mode. ENABLE LOG Enables the display of all protocol commands sent to the remote host. ENABLE PARSE Enables the expansion of file names. ENABLE Enables the sending of the FTP protocol PORT_COMMAND PORT command. ENABLE REPLY Enables the display of all responses from the remote host. ENABLE Enables the display of the pound sign (#) TRANSFER_ for each 1K bytes of data transferred. VERIFICATION ENABLE Enables the OpenVMS-to-OpenVMS transfer VMS_PLUS mode. HELP Invokes help. QUOTE Sends FTP commands to the remote host without local interpretation. SET TYPE Defines the data representation for file transfers. SHOW STATUS Displays the current FTP parameter settings and, if you have an open connection, the name of the connected host. SPAWN Starts a subprocess at the DCL prompt.
2 – FTP Conventions
Use the following rules for command syntax, quotation marks, and wildcard characters when you type FTP command lines. o Command syntax With the FTP command and most of the commands at the FTP prompt, you can use either DCL or UNIX command syntax. For example, the DCL DIRECTORY and the UNIX ls commands produce the same results o Quotation marks When you communicate with a non-OpenVMS host, you might need to enclose the following within quotation marks: o UNIX path names o UNIX file names with slashes o Lowercase or mixed-case host names, user names, passwords, file names, and command lines As shown in the following example, enclose UNIX path names with quotation marks: FTP> put MY.DOC "/usr/users/evt/my.doc" 200 PORT command successful. 150 Opening ASCII mode data connection for /usr/users/evt/mydoc (130.180.4.8,1789). 226 Transfer complete. local: WORK1$:[VANA]MY.DOC;2 remote: /usr/users/evt/my.doc 289 bytes sent in 00:00:00.01 seconds (20.15 Kbytes/s) o Wildcards You can use wildcards in the following FTP commands: DELETE, DIRECTORY, GET, PUT, MGET, MPUT, MDELETE, and MLS. The wildcard characters recognized by FTP include the following: o The percent sign (%) to represent an individual character o The question mark (?) to represent an individual character o The asterisk (*) to represent multiple characters If any of these characters are part of a file name but are not used as a wildcard, you can disable recognition of these characters as wildcards by either enclosing the file name in quotation marks or using the DISABLE PARSE command. o Qualifiers In DCL command lines, you can place a command qualifier anywhere on the command line. It is a good practice to follow the OpenVMS recommendation of placing the qualifier after the command name.
3 – Starting FTP
You can start an FTP session in any of the following ways: o At the DCL prompt, enter the FTP command and specify a remote host. o At the DCL prompt, enter the FTP command with no parameters. At the FTP prompt, enter the CONNECT or open command, specifying a remote host. o By using the /FTP qualifier on the DCL commands COPY and DIRECTORY. o Invoke and use FTP from a command procedure You must connect to a remote host before you can enter an FTP command that affects or displays files on the remote host. You can invoke FTP and, without first connecting to a remote host, enter the FTP commands that customize the FTP environment. When you establish an FTP connection, the remote user name defaults to your user name on the local system. If you have a different user name on the remote system, do one of the following: o On the FTP command line, enter the /USERNAME qualifier. o At the user name prompt, type your remote user name. For example: $ FTP SITE1 220 site1.midwest.billing.bench.com FTP server (Version 5.0) ready Connected to SITE1.midwest.billing.bench.com. Name (SITE1:antel): crowe <Return> 331 Username CROWE requires a Password Password: <Return> 230 User logged in If your connection is with another OpenVMS host, it executes your LOGIN.COM procedure. You can use your LOGIN.COM command procedure to customize the environment for your FTP sessions.
3.1 – Examples
The following example connects to host XENO using the FTP command: $ FTP XENO /USER="bennings" /PASSWORD="keysimpl"<Return> 220 xeno FTP Server (UNIX Version 5.60) ready Connected to XENO.site1.acctg.com. 230 User logged in FTP> In the following example, user dave invokes FTP and connects to UNIX host sanfran using the CONNECT command: $ FTP <Return> FTP> CONNECT SANFRAN <Return> 220 sanfran.golden.com FTP server (UNIX Version 5.60) ready Connected to sanfran.golden.com. Name (sanfran:dave): <Return> 331 Password required for dave Password: <Return> 230 User logged in FTP>
4 – Anonymous FTP
Anonymous user access, also called Anonymous FTP, lets you make an FTP connection to a remote host by specifying the name ANONYMOUS (or another name defined by the system manager). With Anonymous FTP, you do not need: o A registered user account on the remote host o To use your own user account, if you have one o To supply a password With Anonymous FTP, you can perform the following actions: o View remote directories - View the guest and public directories with the FTP command DIRECTORY. - If set up, the public directory called GUEST$PUBLIC has general bulletin-board information. It contains files of interest to FTP users. o Copy files - Enter GET and PUT commands to copy files to and from GUEST$PUBLIC. - The public area is read-only. You can enter the GET command to copy files from the remote host to your local system. Optionally, there may be an ANONYMOUS$USER directory where you can perform the following actions: - Delete files - Create directories - Delete directories - Rename files - Rename directories The system manager sets up the access restrictions for Anonymous FTP that determine the availability of features. NOTE GUEST$PUBLIC and ANONYMOUS$USER are devices names for directories that may be set up by the system manager. See the HP TCP/IP Services for OpenVMS Management manual for more information.
4.1 – Examples
In the following example, UNIX user williams uses Anonymous FTP to connect to the ANONYMOUS account on OpenVMS host TRACTPLAN. Rather than prompt for a password, TRACTPLAN asks for the user name. % ftp tractplan Connected to tractplan.green_dev.org. 220 tractplan FTP Server (Version 5.1) ready Name (tractplan:williams): anonymous 331 Guest login ok, send ident as password Password: williams@tractplan.edu 230 Guest login ok, access restrictions apply
5 – Exiting FTP
You can end an FTP session and return to the DCL prompt by entering the EXIT, quit, or bye commands or by pressing Ctrl/Z. The following examples close a connection with the remote host and exit FTP. FTP> EXIT 221 Goodbye. $ FTP> quit 221 Goodbye. $ To close a connection and remain at the FTP prompt, use the DISCONNECT or close command.
5.1 – Examples
The following examples show how to close a connection, if one is open, and remain at the FTP prompt for you to continue using FTP. FTP> DISCONNECT 221 Goodbye. FTP> FTP> CLOSE 221 Goodbye. FTP>
6 – Viewing Remote Directories
Use the DIRECTORY command to list the files and associated information in remote directories. For example, the following command lists the files in the default directory on a remote UNIX host (assuming the user already has connected to the remote host): FTP> DIRECTORY 200 PORT command successful 150 Opening ASCII mode data connection for /bin/ls (130.180.4.8,1312) total 6303 -rw-rw-r-- 1 milgrom users 1 Jan 9 2002 #UNTITLED# -rw------- 1 milgrom users 4 Apr 11 2002 .Xauthority -rwxr-xr-x 1 milgrom users 1499 Feb 3 2002 .cshrc drwxr-xr-x 11 milgrom users 8192 Jan 9 2002 .dt -rwxr-xr-x 1 milgrom users 3970 Dec 13 2002 .dtprofile)
7 – Default Directory
During an FTP session, you can display or change the current default directory either on the remote host or on your local host. To display the default (working) directory on the remote host, use the SHOW DEFAULT command, as in the following example: FTP> SHOW DEFAULT 257 "/usr/users" is the current directory. To display the working directory on the local host, use the SHOW DEFAULT command with the /LOCAL qualifier, as in the following example: FTP> SHOW DEFAULT/LOCAL Local directory is DISK$6:[MANAGER]. To change the default directory on the remote host, use the SET DEFAULT command. The following example shows how to change the default directory on a remote UNIX host to /usr/users/robert: FTP> SET DEFAULT "/usr/users/robert" 250 CWD command successful. or FTP> SET DEFAULT "~robert" To change back to your login default directory, specify a tilde (~) alone, as follows: FTP> SET DEFAULT ~ 250 CWD command successful. FTP> pwd 257 "/usr/users/robert" is current directory.
8 – Creating and Deleting Directories
To create a directory on a connected remote host, use the CREATE/DIRECTORY command. The following example creates a subdirectory LOCAL_ACCTS in the current working directory on the connected remote OpenVMS host. FTP> CREATE/DIRECTORY [.LOCAL_ACCTS] To delete a directory, use the DELETE/DIRECTORY command as in the following example. The command deletes the directory created in the preceding example. FTP> DELETE/DIRECTORY LOCAL_ACCTS.DIR;*
9 – Copying Files
To copy files from a remote host to your local host, use the GET command. To copy files from your local host to a remote host, use the PUT command. To use these commands, you must have an active FTP session with a remote host. You can enter any number of commands during the session. You can also use the COPY/FTP command to copy files across the network using TCP/IP. For more information on this command, type HELP COPY/FTP at the DCL prompt. FTP resolves the differences between UNIX file systems and OpenVMS file systems automatically. By default, the PUT command copies files to UNIX systems using lowercase file names without version numbers. If you use a wildcard to copy all versions of a file and do not specify an output file, the following occurs: o The version numbers become the last element of the copied files. o Semicolons are converted to periods.
9.1 – Store Unique Feature
The Store Unique (STOU) feature allows you to control how file version numbers are treated when you copy (PUT) files from local to remote hosts. After connecting to the remote host, you toggle the Store Unique feature on and off by issuing the sunique command at the FTP prompt, as follows: FTP> sunique Store unique on. FTP> sunique Store unique off. FTP> sunique Store unique on. The Store Unique feature behaves differently when copying files between OpenVMS and UNIX. It also behaves differently if you use wildcards or specify version numbers. The following table shows the results when you copy the file text.txt from OpenVMS to UNIX. File test.txt Exists Store on UNIX Unique FTP Command System On Store Unique Off FTP> PUT No text.txt text.txt text.txt FTP> PUT Yes text.txt.1 text.txt text.txt The next table shows the results when you copy the file text.txt;* from OpenVMS to UNIX. Files test.txt.1 test.txt.2 Exist on Store UNIX Unique FTP Command System On Store Unique Off FTP> PUT No text.txt.2 text.txt.2 text.txt;* text.txt.1 text.txt.1 FTP> PUT Yes text.txt.2text.txt.2 text.txt;* text.txt.1 text.txt.1.1
9.2 – VMS Plus Mode
FTP performs fast file transfers between two OpenVMS systems by using VMS Plus Mode. When FTP identifies file transfers between two OpenVMS hosts running TCP/IP Services, it transfers files in large blocks rather than in small records. VMS Plus Mode greatly increases the transfer speed and preserves all Record Management Services (RMS) file attributes. FTP automatically disables VMS Plus Mode when your session is with a UNIX host or with an OpenVMS host not running TCP/IP Services.
9.3 – Preserving File Attributes
When you transfer OpenVMS files to a UNIX system and back again, some record attributes might be lost. To preserve all RMS file attributes, use the /FDL qualifier (File Definition Language) with the GET and PUT commands. You might also need to use the SET TYPE command to determine the type of file transfer: o Specifying SET TYPE ASCII results in a sequential file with variable records. Select this type when transferring ASCII text files. o Specifying SET TYPE IMAGE results in a sequential file with fixed records of 512 bytes. Select this type when transferring non-ASCII files, such as binary files or executable image files. For example, to transfer an executable image to a remote UNIX host, follow these steps: 1. Specify the IMAGE data type: FTP> SET TYPE IMAGE 2. Transfer the file to the remote host. At the same time, create and transfer a secondary file with the file's OpenVMS record attributes: FTP> PUT/FDL file To retrieve the file from a remote UNIX host, follow these steps: 1. Specify the IMAGE data type: FTP> SET TYPE IMAGE 2. Retrieve the file from the remote host after retrieving and using the secondary file containing the file's OpenVMS record attributes: FTP> GET/FDL file.dat
9.4 – Examples
1. In the following example, the PUT/FDL command does the following: o Creates the FDL file cygnet.bckfdl on the remote host with the RMS attributes of file STAT.BCK. o Transfers the data in STAT.BCK and puts it in to cygnet.bckfdl on the remote host. FTP> PUT/FDL STAT.BCK CYGNET.BCK 200 TYPE set to ASCII 200 PORT command successful 150 Opening data connection for cygnet.bckfdl (130.180.4.8,1028) 226 Transfer complete local: cygnet.bckfdl remote: cygnet.bckfdl 846 bytes sent in 00:00:00.03 seconds 200 TYPE set to IMAGE 200 PORT command successful 150 Opening data connection for cygnet.bck (130.180.4.8,1029) 226 Transfer complete local: STAT.BCK remote: cygnet.bck 8152 bytes sent in 00:00:00.12 seconds In the following example, the GET/FDL command performs the following actions: o Transfers the FDL file cygnet.bckfdl from the remote host to the local host. o Uses this file to re-create the file STAT.BCK, with all of its original RMS attributes, on the local host. o Transfers the data in cygnet.bck to the new local file STAT.BCK. FTP> GET/FDL CYGNET.BCK STAT.BCK 200 TYPE set to ASCII 200 PORT command successful 150 Opening data connection for cygnet.bckfdl (130.180.4.8,1028) 226 Transfer complete local: cygnet.bckfdl remote: cygnet.bckfdl 846 bytes sent in 00:00:00.03 seconds 200 TYPE set to IMAGE 200 PORT command successful 150 Opening data connection for cygnet.bck (130.180.4.8,1029) 226 Transfer complete local: STAT.BCK remote: cygnet.bck 8152 bytes sent in 00:00:00.12 seconds
9.5 – Transfer Mode
TCP/IP Services supports only STREAM mode for data transfer. STREAM mode transmits the data as a stream of bytes.
9.6 – File Structure
TCP/IP Services supports transfers of ASCII (stream, records with variable length) and IMAGE (binary, records fixed at 512 bytes) files.
10 – Renaming and Deleting Files
To change the name of a remote file, use the FTP command RENAME. The following command renames file YEAR.DAT to YEAR96.DAT on the connected remote host: FTP> RENAME YEAR.DAT YEAR96.DAT To remove a remote file, use the FTP command DELETE. The following command deletes all versions of file YEAR.DAT on the connected remote VMS host: FTP> DELETE YEAR.DAT;*
11 – Viewing File Contents
To display the contents of a file on a connected remote host, use the FTP command VIEW and specify the file name. If the file is not in your current working directory, include the directory name in the file specification. The following example shows how to display the contents of file ENG.DIS located in the remote working directory: FTP> VIEW/PAGE ENG.DIS usrm::"khuna@jnet.com" pobox::bearse yield::timms usrm::"lerry@muster.cudenver.edu" sam nm%us1rmc::"ldutton@TopCom.com" . . .
12 – Appending Files
The FTP command APPEND allows you to concatenate a local file to a file on a connected remote host. The following command appends local file JUL_DEC.DAT to file YEAR.DAT on the connected remote host KALI. FTP> APPEND JUL_DEC.DAT YEAR.DAT 200 PORT command successful 150 Opening data connection for year.dat. (130.180.4.8,1108) 226 Append transfer complete local:large.txt remote:remote.dat 15596 bytes sent in 00:00:00.10 seconds (152.30 Kbytes/s)
13 – Customizing FTP
You can modify the way FTP transfers files, depending on the following criteria: o The operating system of the remote host o The applications you use o Whether you want wildcard name expansion o The information you want displayed during processing The following are a few of the FTP commands that control FTP command processing: o ENABLE/DISABLE LOG Enables or disables the display of FTP commands sent to the remote host. o ENABLE/DISABLE PARSE Enables or disables the expansion of file name specifications. o ENABLE/DISABLE REPLY Enables or disables the display of all responses from the remote host. o QUOTE Sends FTP commands directly to the remote host without local interpretation. The preceding commands control the way FTP displays command processing information and status. The SHOW STATUS command displays the current status of the FTP client (your local host) and, if you have a connection, of the remote host. By default, FTP returns multiple lines of error messages (MULTILINE is enabled). The first line explains the general problem, while subsequent lines provide details to help you diagnose the source of the problem. These lines may include operating system as well as FTP messages. Applications that use FTP to transfer files under program control often do not need the extra messages returned. To disable the MULTILINE feature, when you supply a password to connect to a remote host, precede the password with a hyphen (-password), as in the following example: $ FTP /USER=SALINGER /PASSWORD=-LETMEIN HAGELS Use the FTP command SHOW STATUS to determine whether the MULTILINE feature is enabled. You can modify the way FTP reacts to errors by using the SET ERROR_LEVEL command. By default, the error level setting is SUCCESS, which means that when FTP is running in batch mode, a warning or error message will cause FTP to exit. (FTP runs in batch mode when FTP commands are executed by a command procedure rather than interactively.) If you do not want FTP to exit upon a warning or error message, you can set the error level to ERROR. For example, in the following command, if the default error level (SUCCESS) is in effect and directory [MILLER.USERS] does not exist, the resulting error would cause FTP to exit. $ FTP CONNECT HAGELS cd [MILLER.USERS] DEL *.*;* EXIT $ If the error level had been set to ERROR, FTP would not exit, and the DELETE command in the command procedure would delete all files in your current working directory. Note that you can also set the error level to WARNING, which causes FTP to tolerate warning messages (but not error messages).
14 – Command Procedures
You can use either OpenVMS or UNIX command syntax in DCL command procedures that use FTP. You can use command procedures to invoke FTP tasks, connecting to a remote host and performing assorted file operations with the remote host and you can use command procedures to customize the FTP environment.
14.1 – Initialization Command Files
Initialization command files can customize your FTP sessions with the SET, ENABLE, and DISABLE commands. These command files are optional. They eliminate the need to enter individual FTP commands, and they run automatically when you invoke FTP. Initialization command files have the following characteristics: o Contain only OpenVMS commands. o Contain only one command per line. o Are generally named SYS$LOGIN:FTPINIT.INI.
14.2 – Examples
The following example shows an FTP initialization command procedure. ! This file, FTPINIT.INI, sets my FTP parameters ! the way I like them. ! ENABLE REPLY ENABLE TRANSFER_VERIFICATION SET DEFAULT/LOCAL [MILLER.WORK] When you invoke FTP, the initialization file generates output such as the following, which displays environment status: $ FTP Reply on. Verbose mode on. Bell off. Hash mark printing on (1024/hash mark). Local directory now SYS$LOGIN_DEVICE:[MILLER.WORK]
14.3 – Setting Error Level
To change the error level, enter the following command, where x is SUCCESS, WARNING, or ERROR: FTP> SET ERROR_LEVEL x o If x is SUCCESS, then WARNING, ERROR, and FATAL cause FTP to exit. o If x is WARNING, then ERROR and FATAL cause FTP to exit. o If x is ERROR, then only FATAL causes FTP to exit. Fatal errors always cause FTP to exit.
15 – DECnet Operations
To copy files to and from a DECnet node, use the standard GET and PUT commands You can copy files to and from DECnet nodes and get remote directory information, if your host and the DECnet node are connected through a host running TCP/IP Services for OpenVMS. Use the full file specification, including the node, device, directory, and file name.
15.1 – Examples
1. The following PUT command copies local file FAX.TXT to DECnet node CURTAIL and renames the file to CURRENT.TXT: FTP> PUT FAX.TXT CURTAIL::DISK$3:[GEARY.KEEPS]CURRENT.TXT 2. The following GET command copies remote OpenVMS file HOUSING.TXT from DECnet node HABTAT and renames the file to HOUSE.TXT: FTP> GET HABTAT::DISK$2:[NATL.UTAH.SWEST]HOUSING.TXT HOUSE.TXT