ftp -s:filename hosts >result.txt 执行脚本,并将结果定向输出到result.txt 脚本内容,如 cd mydir ls bye 可以将mydir命令列出 然后使用批处理分析result.txt 从150 Opening ASCII mode data connection for file list.的下一行开始算,直到226 Transfer complete都是要下载的内容 然后用批处理加ftp脚本,使用get命令逐个下载
但实际过程中发现,在FTP脚本中使用get有问题,提示参数错误,无法使用。
查看了ftp的帮助ftp -?
G:>ftp -?
Transfers files to and from a computer running an FTP server service (sometimes called a daemon). Ftp can be used interactively.
-v Suppresses display of remote server responses. -n Suppresses auto-login upon initial connection. -i Turns off interactive prompting during multiple file transfers. -d Enables debugging. -g Disables filename globbing (see GLOB command). -s:filename Specifies a text file containing FTP commands; the commands will automatically run after FTP starts. -a Use any local interface when binding data connection. -A login as anonymous. -w:buffersize Overrides the default transfer buffer size of 4096. host Specifies the host name or IP address of the remote host to connect to.
Notes: - mget and mput commands take y/n/q for yes/no/quit. - Use Control-C to abort commands.