ftp コマンドを入力して接続するディレクトリは、ローカルの作業用ディレクトリ、つまりこの操作のコピー元ディレクトリになります。
ftp により接続します。
ftp によりリモートシステムへ接続する方法を参照してください。
コピー先ディレクトリに変更します。
ftp> cd target-directory |
ローカルシステムでオートマウンタを使用中であれば、/home の下に自分のホームディレクトリと並行してリモートシステムのユーザーのホームディレクトリが表示されるので注意してください。
コピー先ディレクトリへの書き込み権があることを確認します。
ftp> ls -l target-directory |
転送タイプを binary に設定します。
ftp> binary |
ファイルを 1 つコピーするには、put コマンドを使用します。
ftp> put filename |
一度に複数のファイルをコピーするには、mput コマンドを使用します。
ftp> mput filename [filename ...] |
個々のファイル名を続けて入力するか、ワイルドカード文字を使用できます。mput コマンドでは、個々のファイルがコピーされ、そのたびに確認を求めるプロンプトが表示されます。
ftp による接続を終了するには、bye と入力します。
ftp> bye |
次の例では、ユーザー kryten はシステム pluto へ ftp により接続し、put コマンドを使用して自分のシステムからシステム pluto の /tmp ディレクトリにファイルをコピーします。
$ cd /tmp 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> put filef 200 PORT command successful. 150 ASCII data connection for filef (129.152.221.238,34356). 226 Transfer complete. ftp> ls 200 PORT command successful. 150 ASCII data connection for /bin/ls (129.152.221.238,34357) (0 bytes). dtdbcache_:0 filea filef files ps_data speckeysd.lock 226 ASCII Transfer complete. 60 bytes received in 0.058 seconds (1.01 Kbytes/s) ftp> bye 221 Goodbye. |
次の例では、同じユーザー kryten は mput コマンドを使用して自分のホームディレクトリから pluto の /tmp ディレクトリに複数のファイルをコピーします。kryten は、個々のファイルについてコピーするか、しないかを選択できることに注意してください。
$ cd $HOME/testdir $ ls test1 test2 test3 $ 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> mput test* mput test1? y 200 PORT command successful. 150 ASCII data connection for test1 (129.152.221.238,34365). 226 Transfer complete. mput test2? y 200 PORT command successful. 150 ASCII data connection for test2 (129.152.221.238,34366). 226 Transfer complete. mput test3? y 200 PORT command successful. 150 ASCII data connection for filef (129.152.221.238,34356). 226 Transfer complete. ftp> bye 221 Goodbye. |