Команда FTP реализует обмен файлами с FTP сервером в командной строке Windows. Утилита ftp.exe входит в стандартный дистрибутив всех версий операционных систем семейства Windows и позволяет выполнять обмен с сервером как в командном, так и в интерактивном режиме.
-v — Отключение вывода на экран ответов с удаленного сервера. -n — Отключение автоматического входа при начальном подключении. -I — Отключение интерактивных запросов при передаче нескольких файлов. -d — Включение отладочного режима. -g — Отключение глобализации имен файлов (см. команду GLOB). -s:имя_файла — Задание текстового файла, содержащего команды FTP, которые будут выполняться автоматически при запуске FTP. -a — Использование локального интерфейса для привязки соединения. -A — Анонимное подключение к серверу. -x:send sockbuf — Переопределение стандартного размера буфера SO_SNDBUF (8192). -r:recv sockbuf — Переопределение стандартного размера буфера SO_RCVBUF (8192). -b:async count — Переопределение стандартного размера счетчика async (3) -w:windowsize — Переопределение стандартного размера буфера передачи (65535). узел — Задание имени или адреса IP удаленного узла, к которому необходимо выполнить подключение.
— команды mget и mput принимают параметры y/n/q как YES/NO/QUIT. — для прекращения выполнения команд нажмите комбинацию клавиш CTRL+C.
При запуске без параметров, FTP переходит в интерактивный режим, ожидая ввода команд пользователем. На экране отображается приглашение — ftp > .
Для получения списка доступных команд можно ввести знак вопроса или команду help
! ? append ascii bell binary bye cd close
literal debug dir disconnect get glob hash help lcd
ls mdelete mdir mget mkdir mls mput open prompt
send put pwd quit quote recv remotehelp rename rmdir
status trace type user verbose
Подсказку по конкретной команде можно получить введя знак вопроса или help и имя команды:
? connect help connect
Список команд FTP клиента Windows:
! — Временный переход из среды FTP в командную строку Windows (CMD.EXE) . Для возврата в FTP используется команда EXIT append добавление данных передаваемого файла в конец существующего. ascii — установка режима передачи файлов в формате ascii (текстовый режим) bell — выдача звукового сигнала по завершении команды . binary — установка режима передачи файлов в двоичном формате bye — завершение сеанса FTP и выход из программы. cd — изменение текущего каталога на удаленном компьютере close — завершение сеанса FTP ( закрытие соединения, открытого командой open ) delete — удаление указанного файла на удаленном компьютере debug — переход в режим отладки dir — вывод содержимого каталога удаленного компьютера disconnect — завершение сеанса ftp. Отключение от сервера FTP без завершения программы. get — прием файла от сервера FTP glob — Переключение метасимвольного расширения имен локальных файлов. По умолчанию этот режим включен и позволяет использовать символы * и ? в шаблонах имен файлов. hash — переключение режима вывода метки хэширования для каждого переданного буфера help — вывод справочной информации по командам FTP lcd — смена рабочего каталога локального компьютера literal — отправка произвольной строки символов в качестве команды ftp ls — вывод содержимого каталога удаленного компьютера mdelete — удаление нескольких файлов mdir — вывод содержимого нескольких каталогов сервера FTP mget — прием нескольких файлов от сервера FTP mkdir — создание каталога на сервере FTP mls — вывод содержимого нескольких каталогов удаленного компьютера mput — отправка нескольких файлов на сервер FTP open — открыть соединение (подключиться) к серверу FTP prompt — изменение строки в приглашения к вводу команд в интерактивном режиме. put — передача одного файла pwd — отобразить имя текущего рабочего каталога на сервере FTP quit — завершение сеанса и выход из программы quote — отправка произвольной команды серверу FTP recv — прием одиночного файла remotehelp — получение справки от сервера FTP rename — переименование файла rmdir — удаление каталога на сервере send — передача одиночного файла status — отображение текущего состояния сеанса — к какому серверу выполнено подключение, тип передаваемых данных, состояние режимов, изменяемых командами FTP trace — переключение режима трассировки type — установка типа передачи файлов user — изменение имени пользователя в сеансе обмена с сервером FTP verbose — переключение режима детализации при выводе сообщений
Как видно из списка перечисленных команд, стандартный клиент FTP в операционных системах Windows поддерживает далеко не полный перечень стандартных ftp-команд и, что самое неприятное, он не поддерживает команду переключения в пассивный режим ( passv ) обмена с сервером FTP, что делает его непригодным для обмена данными с серверами FTP, подключение к которым выполняется с использованием технологии трансляции сетевых адресов NAT . Другими словами, для обмена файлами с внешними, по отношению к подсети клиента, серверами, стандартный FTP-клиент не подходит. Это касается всех версий Windows, включая и Windows 10. Именно этот факт предопределяет область использования утилиты ftp.exe — только в локальных сетях, где возможно прямое TCP-соединение между клиентом и сервером.
Пример сессии с использованием клиента FTP Windows:
open 192.168.1.1 — открыть соединение с сервером 192.168.1.1 user admin — использовать имя пользователя admin при подключении к серверу. В ответ на эту команду сервера запросит пароль. adminpass — ввод пароля для пользователя admin ls — отобразить список файлов и папок в удаленном каталоге get myfile.txt — принять файл myfile.txt из удаленного каталога в текущий локальный каталог. lcd C:\files — сменить текущий локальный каталог. get myfile.txt — принять файл myfile.txt из удаленного каталога в текущий локальный каталог ( C:\files ) .
При использовании FTP клиента Windows в командных файлах, часто применяется запуск программы в режиме управления командами FTP, записанными в текстовый файл.
Windows ftp client cmd
This is a list of the commands available when using the Microsoft Windows command-line FTP client (requires TCP/IP to be installed). All information is from the Windows NT help files. If you need to use the «raw» FTP commands instead of these interpreted commands (for example, if you’re writing your own FTP client), please consult this list instead.
List of FTP commands for the Microsoft command-line FTP client
Command-line options
-v — Suppresses verbose display of remote server responses.
-n — Suppresses auto-login upon initial connection.
-i — Turns off interactive prompting during multiple file transfers.
-d — Enables debugging, displaying all ftp commands passed between the client and server.
-g — Disables filename globbing, which permits the use of wildcard chracters in local file and path names.
-s:filename — Specifies a text file containing ftp commands; the commands will automatically run after ftp starts. No spaces are allowed in this parameter. Use this switch instead of redirection (>).
-a — Use any local interface when binding data connection.
-w:windowsize — Overrides the default transfer buffer size of 4096.
computer — Specifies the computer name or IP address of the remote computer to connect to. The computer, if specified, must be the last parameter on the line.
Client commands
! — Runs the specified command on the local computer
? — Displays descriptions for ftp commands
append — Appends a local file to a file on the remote computer
ascii — Sets the file transfer type to ASCII, the default
bell — Toggles a bell to ring after each file transfer command is completed (default = OFF)
binary — Sets the file transfer type to binary
bye — Ends the FTP session and exits ftp
cd — Changes the working directory on the remote computer
close — Ends the FTP session and returns to the command interpreter
debug — Toggles debugging (default = OFF)
delete — Deletes a single file on a remote computer
dir — Displays a list of a remote directory’s files and subdirectories
disconnect — Disconnects from the remote computer, retaining the ftp prompt
get — Copies a single remote file to the local computer
hash — Toggles hash-sign (#) printing for each data block transferred (default = OFF)
help — Displays descriptions for ftp commands
lcd — Changes the working directory on the local computer
literal — Sends arguments, verbatim, to the remote FTP server
ls — Displays an abbreviated list of a remote directory’s files and subdirectories
mdelete — Deletes one or more files on a remote computer
mdir — Displays a list of a remote directory’s files and subdirectories
mget — Copies one or more remote files to the local computer
mkdir — Creates a remote directory
mls — Displays an abbreviated list of a remote directory’s files and subdirectories
mput — Copies one or more local files to the remote computer
open — Connects to the specified FTP server
prompt — Toggles prompting (default = ON)
put — Copies a single local file to the remote computer
pwd — Displays the current directory on the remote computer (literally, «print working directory»)
quit — Ends the FTP session with the remote computer and exits ftp (same as «bye»)
quote — Sends arguments, verbatim, to the remote FTP server (same as «literal»)
recv — Copies a remote file to the local computer
remotehelp — Displays help for remote commands
rename — Renames remote files
rmdir — Deletes a remote directory
send — Copies a local file to the remote computer (same as «put»)
status — Displays the current status of FTP connections
trace — Toggles packet tracing (default = OFF)
type — Sets or displays the file transfer type (default = ASCII)
user — Specifes a user to the remote computer
verbose — Toggles verbose mode (default = ON)
Parameter(s): command — Specifies the command to run on the local computer. If command is omitted, the local command prompt is displayed; type «exit» to return to ftp.
Parameter(s): command — Specifies the name of the command about which you want a description. If command is not specified, ftp displays a list of all commands.
append
Syntax: append local-file [remote-file]
Parameter(s): local-file — Specifies the local file to add. remote-file — Specifies the file on the remote computer to which local-file will be added. If remote-file is omitted, the local filename is used for the remote filename.
ascii
Note FTP supports two file transfer types, ASCII and binary image. ASCII should be used when transferring text files. See also binary.
In ASCII mode, character conversions to and from the network standard character set are performed. For example, end-of-line characters are converted as necessary, based on the target operating system.
binary
Note FTP supports two file transfer types, ASCII and binary image. Binary should be used when transferring executable files. In binary mode, the file is moved byte-by-byte. See also ascii.
Syntax: cd remote-directory
Parameter(s): remote-directory — Specifies the directory on the remote computer to change to.
close
debug
delete
Syntax: delete remote-file
Parameter(s): remote-file — Specifies the file to delete.
Syntax: dir [remote-directory] [local-file]
Parameter(s): remote-directory — Specifies the directory for which you want to see a listing. If no directory is specified, the current working directory on the remote computer is used. local-file — Specifies a local file to store the listing. If not specified, output is displayed on the screen.
disconnect
Syntax: get remote-file [local-file]
Parameter(s): remote-file Specifies the remote file to copy.
local-file Specifies the name to use on the local computer. If not specified, the file is given the remote-file name.
Parameter(s): command — Specifies the name of the command about which you want a description. If command is not specified, ftp displays a list of all commands.
Parameter(s): directory — Specifies the directory on the local computer to change to. If directory is not specified, the current working directory on the local computer is displayed.
literal
Syntax: literal argument [ . ]
Parameter(s): argument — Specifies the argument to send to the FTP server.
Syntax: ls [remote-directory] [local-file]
Parameter(s): remote-directory — Specifies the directory for which you want to see a listing. If no directory is specified, the current working directory on the remote computer is used. local-file — Specifies a local file to store the listing. If not specified, output is displayed on the screen.
mdelete
Syntax: mdelete remote-files [ . ]
Parameter(s): remote-files — Specifies the remote files to delete.
Syntax: mdir remote-files [ . ] local-file
Parameter(s): remote-files — Specifies the directory for which you want to see a listing. Remote-files must be specified; type «-» to use the current working directory on the remote computer. local-file — Specifies a local file to store the listing. Type «-» to display the listing on the screen.
Parameter(s): remote-files — Specifies the remote file(s) to copy to the local computer.
mkdir
Syntax: mkdir directory
Parameter(s): directory — Specifies the name of the new remote directory.
Syntax: mls remote-files [ . ] local-file
Parameter(s): remote-files — Specifies the files for which you want to see a listing. Remote-files must be specified; type «-» to use the current working directory on the remote computer. local-file — Specifies a local file to store the listing. Type «-» to display the listing on the screen.
Parameter(s): local-files — Specifies the local files to copy to the remote computer.
Syntax: open computer [port]
Parameter(s): computer — Specifies the remote computer to connect to. Computer can be specified by IP address or computer name (a DNS or HOSTS file must be available). If auto-login is on (default), FTP also attempts to automatically log the user in to the FTP server (see Ftp command-line options to disable auto-login). port — Specifies a port number to use to contact an FTP server.
prompt
Syntax: put local-file [remote-file]
Parameter(s): local-file — Specifies the local file to copy. remote-file — Specifies the name to use on the remote computer. If not specified, the file is given the local-file name.
quote
Parameter(s): argument — Specifies the argument to send to the FTP server.
Syntax: recv remote-file [local-file]
Parameter(s): remote-file — Specifies the remote file to copy. local-file — Specifies the name to use on the local computer. If not specified, the file is given the remote-file name.
remotehelp
Syntax: remotehelp [command]
Parameter(s): command — Specifies the name of the command about which you want help. If command is not specified, ftp displays a list of all remote commands.
rename
Syntax: rename filename newfilename
Parameter(s): filename — Specifies the file you want to rename. newfilename — Specifies the new filename.
rmdir
Syntax: rmdir directory
Parameter(s): directory — Specifies the name of the remote directory to delete.
Syntax: send local-file [remote-file]
Parameter(s): local-file — Specifies the local file to copy. remote-file — Specifies the name to use on the remote computer. If not specified, the file is given the local-file name.
status
trace
Parameter(s): type-name — Specifies the file transfer type; the default is ASCII. If type-name is not specified, the current type is displayed.
Note FTP supports two file transfer types, ASCII and binary image.
ASCII should be used when transferring text files. In ASCII mode, character conversions to and from the network standard character set are performed. For example, end-of-line characters are converted as necessary, based on the destination’s operating system.
Binary should be used when transferring executable files. In binary mode, the file is moved byte-by-byte.
Syntax: user user-name [password] [account]
Parameter(s): user-name — Specifies a user name with which to log in to the remote computer. password — Specifies the password for user-name. If not specified, but required, ftp prompts for the password. account — Specifies an account with which to log on to the remote computer. If account is not specified, but required, ftp prompts for the account.