System Administration Guide, Volume 2

How to Copy Files From a Remote System (ftp)

  1. Change to a directory on the local system where you want the files from the remote system to be copied.


    $ cd target-directory
    
  2. Establish an ftp connection.

    See "How to Open an ftp Connection to a Remote System".

  3. Change to the source directory.


    ftp> cd source-directory
    

    If your system is using the automounter, the home directory of the remote system's user appears parallel to yours, under /home.

  4. Make sure you have read permission for the source files.


    ftp> ls -l
    
  5. To copy a single file, use the get command.


    ftp> get filename 
    
  6. To copy multiple files at once, use the mget command.


    ftp> mget filename [filename ...]

    You can supply a series of individual file names and you can use wildcard characters. The mget command will copy each file individually, asking you for confirmation each time.

  7. Close the ftp connections.


    ftp> bye
    

Examples--Copying Files From a Remote System (ftp)

In this example, the user kryten opens an ftp connection to the system pluto, and uses the get command to copy a single file from the /tmp directory:


$ cd $HOME
ftp pluto
Connected to pluto.
220 pluto FTP server (SunOS 5.8) ready.
Name (pluto:kryten): kryten
331 Password required for kryten.
Password: xxx
230 User kryten logged in.
ftp> cd /tmp
250 CWD command successful.
ftp> ls
200 PORT command successful.
150 ASCII data connection for /bin/ls (129.152.221.238,34344) 
(0 bytes).
dtdbcache_:0
filea
files
ps_data
speckeysd.lock
226 ASCII Transfer complete.
53 bytes received in 0.022 seconds (2.39 Kbytes/s)
ftp> get filea
200 PORT command successful.
150 ASCII data connection for filea (129.152.221.238,34331) 
(0 bytes).
226 ASCII Transfer complete.
ftp> bye
221 Goodbye.

In this example, the same user kryten uses the mget command to copy a set of files from the /tmp directory to his home directory. Note that kryten can accept or reject individual files in the set.


$ ftp> cd /tmp
250 CWD command successful.
ftp> ls files
200 PORT command successful.
150 ASCII data connection for /bin/ls (129.152.221.238,34345) 
(0 bytes).
fileb
filec
filed
226 ASCII Transfer complete.
remote: files
21 bytes received in 0.015 seconds (1.36 Kbytes/s)
ftp> cd files
250 CWD command successful.
ftp> mget file*
mget fileb? y
200 PORT command successful.
150 ASCII data connection for fileb (129.152.221.238,34347) 
(0 bytes).
226 ASCII Transfer complete.
mget filec? y
200 PORT command successful.
150 ASCII data connection for filec (129.152.221.238,34348) 
(0 bytes).
226 ASCII Transfer complete.
mget filed? y
200 PORT command successful.
150 ASCII data connection for filed (129.152.221.238,34351) 
(0 bytes).
226 ASCII Transfer complete.200 PORT command successful.
ftp> bye
221 Goodbye.