With FTP, you can view the remote working directory, change
remote directories, and view or save a listing of the contents of
remote directories.
Viewing the Remote Working Directory |
 |
The PWD command is used to list the name of the remote working
directory. The content of the information displayed by PWD is dependent on the remote system.
For example, a UNIX implementation could display:
ftp> PWD 251 "/users/myname" is the current working directory |
Viewing the Contents of a Remote Directory |
 |
To list the contents of the remote working directory use the DIR command. The contents displayed using the DIR command are dependent on the remote host directory listing facilities.
In the sample below, the working directory is mytest. The first entry is a directory, the remaining
entries are files.
150 Opening data connection for /bin/ls -l (123.50.42.32,50895) (0 bytes). total 33 |
drwxrwxrwx 1 myname guest 10 Feb 13 18:44 ftest -rw-rw-rw- 1 myname guest 100 Feb 12 18:42 file1 -rw-rw-rw- 1 myname guest 100 Feb 12 18:42 file2 -rw-rw-rw- 1 myname guest 110 Feb 13 18:43 testt |
nnn bytes received in n.nn seconds (n.nn Kbytes/sec) |
To list the contents of another directory, enter the DIR command followed by a valid remote directory name:
The LS command provides a consistent display of directory contents
for unlike computer systems. One item per line is displayed. For
example:
ftp> LS 200 PORT command okay. 150 Opening data connection for /bin/ls (123.50.42.32,50896) (0 bytes). ftest file1 file2 testt 226 transfer complete |
Listing Directory Information to a Local File |
 |
You can transfer remote directory information to a local file
with the LS or DIR commands using the following form (assuming a remote
host UNIX file system):
ftp> DIR [remotedirectory/]filename localfile |
or,
ftp> LS [remotedirectory/]filename localfile |
The format of remotedirectory/filename is dependent on the remote system implementation.
The filename part can contain metacharacters (wildcard characters) supported
by the remote system. Some metacharacters supported by the HP 9000
are asterisk (*), and question mark (?).
For example, to transfer a listing of all files in the working
directory to your local file REMDIR, enter:
To transfer the contents of the directory named ftest beginning with the letter R to local file REMDIR1, enter:
Changing Directories |
 |
To change directories in the remote account you are using,
enter the CD command as follows:
Where remotedirectory is the directory you wish to access.
The following example shows a user logged in to an HP 9000
as "myname" who checks the current directory, changes directories,
then checks the new current directory.
ftp> PWD 251 "/users/myname" is the current working directory. ftp> CD test 200 CWD command okay. ftp> PWD 251 "/users/myname/test" is the current working directory. ftp> CD .. 200 CWD command okay. ftp> PWD 251 "/users/myname" is the current working directory. |