$ ftp osku01 Connected to osku01.osa.dec.com. 220 osku01.osa.dec.com FTP server (OSF/1 Version 5.60) ready. Name (osku01:yakoshi): 331 Password required for yakoshi. Password: ******** 230 User yakoshi logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> quit 221 Goodbye. $ ftp -n osku01 Connected to osku01.osa.dec.com. 220 osku01.osa.dec.com FTP server (OSF/1 Version 5.60) ready. ftp> user (username) yakoshi 331 Password required for yakoshi. Password: ******** 230 User yakoshi logged in. ftp> quit 221 Goodbye.
$ ftp osaka Connected to osaka. 220 osaka FTP server (OSF/1 Version 5.60) ready. Name (osaka:yakoshi): root 530 User root access denied. Login failed. Remote system type is UNIX. Using binary mode to transfer files. ftp> user (username) root 530 User root access denied. Login failed. ftp> quit 221 Goodbye.
ftp> status Connected to osaka. No proxy connection. Mode: stream; Type: binary; Form: non-print; Structure: file Verbose: on; Bell: off; Prompting: on; Globbing: on Store unique: off; Receive unique: off Case: off; CR stripping: on Ntrans: off Nmap: off Hash mark printing: off; Use of PORT cmds: on
ftp> mget s* mget sh39660? mget smdbs ? y 200 PORT command successful. 150 Opening BINARY mode data connection for smdbs (xx.xx.xx.xx) (6189 bytes). 226 Transfer complete. 6189 bytes received in 0.065 seconds (92 Kbytes/s)
$ ftp osaka onnected to osaka. 220 osaka FTP server (OSF/1 Version 5.60) ready. Name (osaka:yakoshi): # 表示されているユーザ名以外でログインする場合は、入力が必要 331 Password required for yakoshi. Password: 230 User yakoshi logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 200 PORT command successful. 150 Opening ASCII mode data connection for file list (xx.xx.xx.xx,4384). init sh39660 aaa ftp> dir drwxrwxrwx 2 root system 512 Dec 3 19:11 .X11-unix -rw-r--r-- 1 root system 15805 Dec 3 15:49 aaa -rw-r--r-- 1 root system 382 Dec 3 14:23 ed8974.err -rwxr-xr-x 1 root system 172032 Feb 22 1994 init srwxrwxrwx 1 wnn system 0 Dec 3 19:11 jd_sockV4 -rwxr-xr-x 1 root system 658990 Dec 3 12:06 pak -rw-r--r-- 1 root system 51 Dec 3 10:26 sh39660 -rw-r--r-- 1 patent system 6189 Dec 5 10:44 smdb-:0.0.defaults -rw-r----- 1 yakoshi system 0 Dec 5 13:49 x 226 Transfer complete. ftp> get aaa local get aaa local 200 PORT command successful. 150 Opening BINARY mode data connection for aaa (xx.xx.xx.xx,4388) (15805 bytes) . 226 Transfer complete. 15805 bytes received in 0.19 seconds (83 Kbytes/s) ftp> quit
まず .netrc のファイル属性は 600 (-rw-------) にしておきます。
これはセキュリティ保護の観点から規定されています。
ファイルの内容は大きく2つに分かれ、ログインに関する情報とマクロ定義部
分です。
ログインに関する情報は、自動実行を行いたい接続先とそのユーザ、パスワー
ドを記述します。
続いてマクロを定義します。マクロは macdef で始まり、先頭がタブで始まる
行は継続とみなされ、空行で終了します。
init とよばれるマクロは ftp がログイン成功後に実行する内容です。
$ ls -l ~/.netrc -rw------- 1 yakoshi os2 387 12月05日 14:06 /usr/users/yakoshi/.netrc $ cat ~/.netrc machine osaka login yakoshi passwd HIMITSU macdef init cd /tmp ← この3行は先頭がタブで始まる ls quit ← ここは空行 $ ftp osaka Connected to osaka. 220 osaka FTP server (OSF/1 Version 5.60) ready. 331 Password required for yakoshi. 230 User yakoshi logged in. cd /tmp 250 CWD command successful. ls 200 PORT command successful. 150 Opening ASCII mode data connection for file list (xx.xx.xx.xx,1217). jd_sockV4 ctf-daemon mhrepl2078 mail019672 Ex02081 ycos.log.dat 226 Transfer complete. quit 221 Goodbye. なお (-n) オプションを指定した場合には自動実行は行なわれません。