ブログ

サイト管理人のブログです。

ブログ一覧

FTP転送

スタートメニューから[プログラム]-[MS-DOSプロンプト]を選択する
MS-DOSウインドウが開き、DOSプロンプトが表示される
ftpを起動する

C:\WINDOWS>ftp
●データを転送するサーバにログインする

apli.cc.sojo-u.ac.jpにログインする

ftp> open apli.cc.sojo-u.ac.jp
Connected to apli.cc.sojo-u.ac.jp.
220 xxxxxxx FTP server ( xxxxxxxxxxxx ) ready.

ユーザIDを入力する (例: g0909123)

User (apli.cc.sojo-u.ac.jp : (none)) : g0909123
331 Password required for g0909123.

パスワードを入力する (表示されません)

Password : xxxxxxxx
User g0909123 logged in.

●ローカルディレクトリを指定

転送するファイルの場所を指定する(例:ホームページデータが A:\homepage にある)

ftp> lcd c:\homepage
Local directory now A:\homepage.

ローカルディレクトリ(転送元)のファイルの確認をする

ftp> !dir
ドライブ A: のボリュームラベルはありません.
ボリュームシリアル番号は 0000-0000
ディレクトリは A:\homepage


. <dir> 99-03-03 10:51 .
.. <dir> 99-03-03 10:51 ..
INDEX~1 HTM 1,640 99-03-03 12:47 index.html
IMAGE01 GIF 4,100 99-03-03 12:37 image01.gif
IMAGE02 GIF 6,396 99-03-03 12:37 IMAGE02.GIF
3 個 12,136 バイトのファイルがあります.
2 ディレクトリ 1,443,840 バイトの空きがあります.

●リモートディレクトリの指定

転送先の場所を指定する(UNIX上のホームページを置くディレクトリは public_html )

ftp> cd public_html
250 CWD command successful.

リモートディレクトリ(転送先)のファイルの確認をする

ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 2
-rw-r--r-- 1 tagami admin 1620 Mar 3 9:18 index.html
226 Transfer complete.
ftp: 75 bytes received in 0.11Seconds 0.68Kbytes/sec.

●転送するファイルの種類にあわせて転送モードを指定

ファイルには、バイナリ形式とASCII形式の2種類があり、 転送する前にファイルにあったモードに切り替える必要があります。また、 モードを間違えて転送するとファイルが壊れるので注意しましょう

ASCII形式:HTMLなどのテキストファイル
バイナリ形式:テキスト以外のファイル(画像、音、プログラムなど)

ASCII形式ファイルを転送するときは

ftp> ascii
200 Type set to A.

バイナリ形式ファイルを転送するときは

ftp> bin
200 Type set to I.

●ファイルの転送

HTMLファイルを転送する( index.html )

ftp> ascii
200 Type set to A.
ftp> put index.html
200 PORT command successful .
150 Opening ASCII mode data connection for index.html.
226 Transfer complete. ftp: 1640 bytes sent in 0.00Seconds 1640000.00Kbytes/sec.

画像ファイルを転送する( image01.gif , image02.gif )

ftp> bin
200 Type set to I.
ftp> put image01.gif
200 PORT command successful.
150 Opening BINARY mode data connection for image01.gif.
226 Transfer complete. ftp: 4100 bytes sent in 0.00Seconds 4100000.00Kbytes/sec.
ftp> put image02.gif
200 PORT command successful.
150 Opening BINARY mode data connection for IMAGE02.GIF.
226 Transfer complete. ftp: 6396 bytes sent in 0.00Seconds 6396000.00Kbytes/sec.
●ファイル名の変更

ファイル転送で、転送先ファイル名を指定しなかった場合、転送先ファイル名が大文字になることがあります。サーバではファイルの大文字と小文字の区別があるので、作成したHTMLで指定したファイル名にあわせる必要があります

put 転送元ファイル名 転送先ファイル名

転送先ファイル名を指定すると指定したファイル名に変更して送ることが出来る


ファイル名の確認
ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 14
-rw-r--r-- 1 tagami admin 6396 Mar 3 13:58 IMAGE02.GIF
-rw-r--r-- 1 tagami admin 4100 Mar 3 13:58 image01.gif
-rw-r--r-- 1 tagami admin 1620 Mar 3 13:54 index.html
226 Transfer complete.
ftp: 210 bytes received in 0.16Seconds 1.31Kbytes/sec.

ファイル名の変更( IMAGE02.GIF が大文字になっているので小文字に変更)

ftp> rename IMAGE02.GIF image02.gif
350 File exists, ready for destination name
250 RNTO command successful.

●参考(ftpコマンド一覧)

ftpコマンドの一覧表示
ftp> help
Commands may be abbreviated. Commands are:

! delete literal prompt send
? debug ls put status
append dir mdelete pwd trace
ascii disconnect mdir quit type
bell get mget quote user
binary glob mkdir recv verbose
bye hash mls remotehelp
cd help mput rename
close lcd open rmdir

コマンド機能の説明表示
ftp> ? ascii
ascii Set ascii transfer type

●ftpを終了する

ftpを終了する

ftp> bye
221 Goodbye.

DOSウインドウを終了する

A:\Windows>exet

DOSウインドウが閉じる

2019年05月07日
» 続きを読む