□ ターミナルでFTP操作する

作成したWEBファイルをアップロードする際に、FTPソフトなどを使う場合が多いと思います。
こうしたツールはウィンドウのGUI(グラフィックユーザーインターフェイスの略)ボタンを マウスクリックするだけで、簡単にファイル転送ができるのでたいへん便利なものですが わざわざソフトをダウンロードしなくても、もともとFTPがあるので利用してみましょう

FTPはターミナルを起動して操作するので、どのOSからでもファイル転送ができる メリットがあります。
ただしGUI環境でなく、コマンドライン上で動作するので テキストによる入力に慣れておく必要があります

Linux・MacOSX・Windows いづれも共通のコマンドを使用することができます。 ただし幾つかのコマンドはWindowsにはないものがありますので ファイルパーミッションを変更するchmodコマンドなどは Windowsターミナル上から行う場合、telnetからftpを操作します

*WindowsXP/98/Me  基本的な操作

ここでは、Windows/ftp.exeを対象としたFTP接続について解説します。 まずはターミナルウィンドウ(コマンドを入力する画面)を起動します NT系ではコマンドプロンプト、98/Me系ではMS-DOSプロンプトと呼ばれています。
スタート>プログラム または スタート>プログラム>アクセサリ と進むとプロンプトのアイコンがあるのでクリックします

□C:/Home/ftp/help.html □□□
C:\WINDOWS>exit
   *ターミナルウィンドウは上のような感じです(MS-DOSにはツールボタンがあります)
   マウスとはまったく操作感が違いますので、最初は戸惑うかもしれません
   誤って全画面表示にしてしまっても慌てずに… Alt + Enter で切り替えられます

   C: は Cドライブ、¥(/)はフォルダ(ディレクトリ)という意味です
   その後に続く>はプロンプトと呼ばれ、コマンド入力が可能な状態を示す記号です
   画面を閉じる時はウィンドウ右上のボタンをクリックするかプロンプト上で exit と入力します

   起動した時点でのカレントディレクトリ(現在の場所)は MS-DOSプロンプトはC:\WINDOWS
   コマンドプロンプトの場合はC:\Documents and Settingsとなります

  接続するには「ftp+半角スペース+接続ホスト名」と入力しEnterを押します

□C:/Home/ftp/help.html □□□
 C:\>ftp 接続するホスト(例:ftp.geocities.jp)




  接続に成功するとユーザー名を入力するプロンプトが出ます

□C:/Home/ftp/help.html □□□
 C:\>ftp ftp.geocities.jp
 Connected to ftp.geocities.jp.
 220-Welcome to the Yahoo! JAPAN GeoCities FTP server.
 220-Need help? Get all details at:
 220-http://help.yahoo.co.jp/help/jp/geo/new/
 220-
 220-No anonymous logins accepted.
 220 Yahoo!
 User (ftp.geocities.jp:(none)): ここにユーザー名を入力


  次にPasswordを入力します。*画面には何も表示されません 

□C:/Home/ftp/help.html □□□
 C:\>ftp ftp.geocities.jp
 Connected to ftp.geocities.jp.
 220-Welcome to the Yahoo! JAPAN GeoCities FTP server.
 220-Need help? Get all details at:
 220-http://help.yahoo.co.jp/help/jp/geo/new/
 220-
 220-No anonymous logins accepted.
 220 Yahoo!
 User (ftp.geocities.jp:(none)): artopix
 331-Enter your Yahoo! JAPAN GeoCities member password
 331
 Password:パスワードを入力(注意!何も表示されません)
 230-You are using 5.3% of your subscribed disk space
 230 You have 14.208 MB of space available
 ftp>

  ls と打ってみましょう(ファイルリストが表示されます)
  *ディレクトリも表示させたい場合は dir と入力します

□C:/Home/ftp/help.html □□□
 220 Yahoo!
 User (ftp.geocities.jp:(none)): artopix
 331-Enter your Yahoo! JAPAN GeoCities member password
 331
 Password:
 230-You are using 5.3% of your subscribed disk space
 230 You have 14.208 MB of space available
 ftp> ls
 200 PORT command successful.
 150 Opening ASCII mode data connection for .
 topics.html
 help.html
 photo_album.html
 guest.html
 information.html
 index.html
 226 Transfer complete.
 ftp: 41 bytes received in 0.05Seconds 0.89Kbytes/sec.

  転送したいファイル(ローカル側)の置いてあるディレクトリ(フォルダ)へ移動します

       lcd +半角スペース+フォルダへのパス
       (例 C:\Documents and Settings\artopix\My Documents)

        *パスに半角スペースを含んでいる場合は"ダブルクォートで挟みます
□C:/Home/ftp/help.html □□□
 topics.html
 help.html
 photo_album.html
 guest.html
 information.html
 index.html
 226 Transfer complete.
 ftp: 41 bytes received in 0.05Seconds 0.89Kbytes/sec.
 ftp> lcd "C:\Documents and Settings\artopix\My Documents"
 Local directory now C:\Documents and Settings\artopix\My Documents.

  ディレクトリへ移動したら次にputコマンドでファイルを転送します

         put +半角スペース+ ファイル名(例 test.html)

         *ファイルまでのパスがあらかじめ分かっている場合は
           ディレクトリを移動せずフルパスで指定ができます

         put +半角スペース+ ファイルパス
           (C:\Documents and Settings\artopix\My Documents\test.html)

          *lsコマンドで転送されているか確認してみましょう
           (カーソルの↑キーを押すと一度入力したコマンドが再度呼び出されます)
□C:/Home/ftp/help.html □□□
 ftp> lcd "C:\Documents and Settings\My Documents\artopix"
 Local directory now C:\Documents and Settings\artopix\My Documents.
 ftp> put test.html
 200 PORT command successful.
 150 Opening ASCII mode data connection for /artopix/test.html .
 226-You are using 1.7% of your subscribed disk space
 226 You have 49.171 MB of space available
 ftp> ls
 200 PORT command successful.
 150 Opening ASCII mode data connection for .
 topics.html
 help.html
 photo_album.html
 guest.html
 information.html
 index.html
 test.html
 226 Transfer complete.
 ftp: 41 bytes received in 0.05Seconds 0.89Kbytes/sec.

  接続を終了するには quit または bye と入力します

□C:/Home/ftp/help.html □□□
 topics.html
 help.html
 photo_album.html
 guest.html
 information.html
 index.html
 226 Transfer complete.
 ftp: 41 bytes received in 0.05Seconds 0.89Kbytes/sec.
 ftp> bye
 221-You have transferred 0 bytes in 0 files
 221-Total traffic for this session was 586 bytes in 1 transfers.
 221-Thank you for using the FTP service on ftp2.geo.yahoo.co.jp.
 221 Goodbye.

*FTPコマンド

   ■コマンド一覧表
   FTPソフトに比べると入力の手間が多く、あまり使い勝手も良くありませんが
   GUIに比べ処理も早く、軽快に動作するので、慣れると手離せなくなります
   コマンドライン派を目指すのなら、是非チャレンジしてみてください
   最初はログイン・ログアウトやファイル表示など、簡単なものから覚えると良いでしょう

   ■バッチファイルでFTP転送する
   スクリプトを使ったFTP自動実行ファイルの作成について解説しています。