Board logo

标题: [求助]初学者请教关于dos下自动下载ftp的问题 [打印本页]

作者: caicainancy     时间: 2008-5-14 16:55    标题: [求助]初学者请教关于dos下自动下载ftp的问题

我想弄一个自动下载ftp数据的批处理程序。
我在cmd.exe里通过一步步的录入命令是能够下载的,如:
      ftp ***.***.***.*** 回车
      username  回车
      password  回车
      cd path  回车
      get file  回车
      .......
我想通过批处理,自动下载,但除了 ftp ***.***.***.***,是dos命令之外,其他的都是ftp服务器自带的命令了,无法自动录入,我对代码是这样写的。
      @echo on
      ftp ***.***.***.***
      username  
      password        
      PAUSE
这里的用户名和密码都无法自动的录入,所以请教大虾一下,如何实现在光标闪烁处自动录入想要录入的字符,先感谢大家了。
作者: pooronce     时间: 2008-5-14 17:07
注意-s 参数的说明
C:\WINDOWS>ftp -?

Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.

FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-A] [-x:sendbuffer] [-r:recvbuffer] [-b:asyncbu
ffers] [-w:windowsize] [host]

  -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.
  -x:send sockbuf Overrides the default SO_SNDBUF size of 8192.
  -r:recv sockbuf Overrides the default SO_RCVBUF size of 8192.
  -b:async count  Overrides the default async count of 3
  -w:buffer size  Overrides the default transfer buffer size of 65535.
  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.

作者: HAT     时间: 2008-5-14 17:08

@echo off
set DstFile=%temp%\TempAcc.txt
>"%DstFile%" echo USERNAME
>>"%DstFile%" echo PASSWORD
>>"%DstFile%" echo bin
>>"%DstFile%" echo get *.txt
start ftp -v -s:"%DstFile%" IPADDRESS
del /q "%DstFile%"
exit

作者: caicainancy     时间: 2008-5-14 17:16
非常感谢2楼和3楼的回复,我爱你们。