FTPのコマンド一覧です。
FTPコマンド | パラメータ | 説明 |
ftp | ftpの接続 | |
USER | ユーザ名 | 指定したユーザー名でログイン |
PASS | パスワード | 指定したユーザ名のパスワード |
ls | -l 詳細情報も表示 | ファイル一覧の表示 |
get | ファイルのダウンロード | |
mget | 複数のファイルをダウンロード | |
prompt | 対話/非対話モードの切り替え | |
put | ファイルのアップロード ※ワイルドカードを使用することで複数ファイルをアップロードする事も可能 | |
mput | 複数のファイルをアップロード | |
ascii | asciiモードに | |
bin | binaryモードに | |
TYPE | 形式オプション A:ASCII I:Image(バイナリ) E:EBCDIC | 転送データの形式を指定 (例:HTMLファイルなどの文字列なら[A]、画像などのバイナリファイルなら[I]など) |
cd | リモートのカレントディレクトリの移動 | |
lcd | ローカルカレントディレクトリ移動 | |
del | リモートのファイルの削除 | |
mdel | ファイルを複数削除する | |
rmdir | リモートのディレクトリ削除 | |
pwd | リモートのカレントディレクトリ表示 | |
!pwd | ローカルカレントディレクトリ表示 | |
mkdir | リモートのディレクトリ作成 | |
bye | 切断 |
目次
FTPコマンド
FTPをコマンドを使用して接続する方法です。
表示されるメッセージはサーバ側のFTPの設定によって違うメッセージが表示されます。
D:\>ftp 127.0.0.1 Connected to 127.0.0.1. 220-Welcome To FTP 220 User (127.0.0.1:(none)): sasuke 331 Enter Your Password Password: 230-/_/_/_/_/_/_/_/_/_/_/_/_ 230- Welcome!!! 230-/_/_/_/_/_/_/_/_/_/_/_/_ 230 Login OK!!!
lsコマンド
lsコマンドはファイル一覧を表示する場合に使用します。
-lオプションが指定でき、-lを指定した場合は詳細情報が表示されます。
-lオプションを指定した場合
ftp> ls -l 200 PORT command successful. 150 Opening data connection. drwxrw-rw- 0 owner 0 Sep 23 02:07 . drwxrw-rw- 0 owner 0 Sep 23 02:07 .. -rwxrw-rw- 0 owner 280 Sep 23 02:06 index.html -rwxrw-rw- 0 owner 144 Sep 23 02:07 test.html -rwxrw-rw- 0 owner 589878 Sep 23 02:07 test.jpg 226 Transfer complete. ftp: 300 bytes received in 0.00Seconds 300000.00Kbytes/sec.
getコマンド
getコマンドはファイルをダウンロードするのに使用します。 以下の指定をします。get ダウンロード元ファイル ダウンロード先
ftp> get index.html c:\index.html 200 PORT command successful. 150 Opening data connection. 226 Transfer complete. ftp: 280 bytes received in 0.00Seconds 280000.00Kbytes/sec.
mgetコマンド
mgetコマンドはファイルを複数ダウンロードするのに使用します。 ワイルドカードを使用することが出来ます。mget ダウンロード元ファイル ダウンロード先
ftp> mget *.html c:\data\ 200 PORT command successful. 150 Opening data connection. 226 Transfer complete. ftp: 280 bytes received in 0.00Seconds 280000.00Kbytes/sec.
putコマンド
putコマンドはファイルをアップロードするためのコマンドです。 以下の指定でアップロードします。 また、ワイルドカードを使用することで、複数のファイルをアップロードする事も可能です。例「*.html」等のファイル名を指定
put ローカルファイル名 リモート先フィル名
ftp> put c:\test2.html test2.html 200 PORT command successful. 150 Opening data connection. 226 Transfer complete.
mputコマンド
複数のファイルをサーバに転送します。
ftp> mput file1 file2 file2
一つ上のディレクトリに戻る場合は「./」を打ちます。
ftp> cd test 250 Requested file action okay, completed. ftp> pwd 257 "/test/" is your directory. ftp> cd ../ 250 Requested file action okay, completed. ftp> pwd 257 "/" is your directory.
delコマンド
ファイルを削除するには「del」コマンドを使用します。
ftp> del test.html 250 Requested file action okay, completed.
rmdirコマンド
リモートのディレクトリを削除します。
ftp> rmdir test 257 "test" directory deleted.
pwdコマンド
カレントディレクトリを表示します。
今どこのディレクトリで作業しているかがわからなくなった時などに使用します。
ftp> pwd 257 "/test/" is your directory.
mkdirコマンド
リモート先にディレクトリを作成するコマンドです。
ftp> mkdir test 257 "test" directory created.
byeコマンド
byeは切断コマンドです。
切断しFTPが終了します。
ftp> bye 221 Good-Bye D:\>
ftp> ls 200 PORT command successful. 150 Opening data connection. . .. index.html test.html test.jpg 226 Transfer complete. ftp: 40 bytes received in 0.03Seconds 1.29Kbytes/sec.
-lオプションを指定した場合
ftp> ls -l 200 PORT command successful. 150 Opening data connection. drwxrw-rw- 0 owner 0 Sep 23 02:07 . drwxrw-rw- 0 owner 0 Sep 23 02:07 .. -rwxrw-rw- 0 owner 280 Sep 23 02:06 index.html -rwxrw-rw- 0 owner 144 Sep 23 02:07 test.html -rwxrw-rw- 0 owner 589878 Sep 23 02:07 test.jpg 226 Transfer complete. ftp: 300 bytes received in 0.00Seconds 300000.00Kbytes/sec.
getコマンド
getコマンドはファイルをダウンロードするのに使用します。 以下の指定をします。get ダウンロード元ファイル ダウンロード先
ftp> get index.html c:\index.html 200 PORT command successful. 150 Opening data connection. 226 Transfer complete. ftp: 280 bytes received in 0.00Seconds 280000.00Kbytes/sec.
mgetコマンド
mgetコマンドはファイルを複数ダウンロードするのに使用します。 ワイルドカードを使用することが出来ます。mget ダウンロード元ファイル ダウンロード先
ftp> mget *.html c:\data\ 200 PORT command successful. 150 Opening data connection. 226 Transfer complete. ftp: 280 bytes received in 0.00Seconds 280000.00Kbytes/sec.
putコマンド
putコマンドはファイルをアップロードするためのコマンドです。 以下の指定でアップロードします。 また、ワイルドカードを使用することで、複数のファイルをアップロードする事も可能です。例「*.html」等のファイル名を指定
put ローカルファイル名 リモート先フィル名
ftp> put c:\test2.html test2.html 200 PORT command successful. 150 Opening data connection. 226 Transfer complete.
mputコマンド
複数のファイルをサーバに転送します。
ftp> mput file1 file2 file2
一つ上のディレクトリに戻る場合は「./」を打ちます。
ftp> cd test 250 Requested file action okay, completed. ftp> pwd 257 "/test/" is your directory. ftp> cd ../ 250 Requested file action okay, completed. ftp> pwd 257 "/" is your directory.
delコマンド
ファイルを削除するには「del」コマンドを使用します。
ftp> del test.html 250 Requested file action okay, completed.
rmdirコマンド
リモートのディレクトリを削除します。
ftp> rmdir test 257 "test" directory deleted.
pwdコマンド
カレントディレクトリを表示します。
今どこのディレクトリで作業しているかがわからなくなった時などに使用します。
ftp> pwd 257 "/test/" is your directory.
mkdirコマンド
リモート先にディレクトリを作成するコマンドです。
ftp> mkdir test 257 "test" directory created.
byeコマンド
byeは切断コマンドです。
切断しFTPが終了します。
ftp> bye 221 Good-Bye D:\>