中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-06-28 15:49
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [求助]初学者请教关于dos下自动下载ftp的问题 查看 665 回复 3
楼 主 [求助]初学者请教关于dos下自动下载ftp的问题 发表于 2008-05-14 16:55 ·  中国 福建 厦门 教育网
新手上路
积分 6
发帖 2
注册 2008-05-14 16:16
18年会员
UID 118664
性别 男
状态 离线
我想弄一个自动下载ftp数据的批处理程序。
我在cmd.exe里通过一步步的录入命令是能够下载的,如:
ftp ***.***.***.*** 回车
username 回车
password 回车
cd path 回车
get file 回车
.......
我想通过批处理,自动下载,但除了 ftp ***.***.***.***,是dos命令之外,其他的都是ftp服务器自带的命令了,无法自动录入,我对代码是这样写的。
@echo on
ftp ***.***.***.***
username
password
PAUSE
这里的用户名和密码都无法自动的录入,所以请教大虾一下,如何实现在光标闪烁处自动录入想要录入的字符,先感谢大家了。
2 发表于 2008-05-14 17:07 ·  中国 上海 电信
中级用户
★★
积分 484
发帖 250
注册 2007-06-05 23:33
19年会员
UID 90372
性别 男
状态 离线
注意-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 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.
3 发表于 2008-05-14 17:08 ·  中国 上海 联通
版主
★★★★★
积分 9,023
发帖 5,017
注册 2007-05-31 19:39
19年会员
UID 89899
性别 男
状态 离线
@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
4 发表于 2008-05-14 17:16 ·  中国 福建 厦门 教育网
新手上路
积分 6
发帖 2
注册 2008-05-14 16:16
18年会员
UID 118664
性别 男
状态 离线
非常感谢2楼和3楼的回复,我爱你们。
论坛跳转: