中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-04 13:14
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » How to use a batch file to automatically log in to an FTP website and upload files
Printable Version  2,907 / 4
Floor1 hantao2000 Posted 2004-06-03 00:00
初级用户 Posts 2 Credits 108
How to use a batch file to automatically log in to an FTP website and upload files via FTP
Floor2 Climbing Posted 2004-06-03 00:00
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
I will take the FTP command of Windows 2003 as an example. Entering ftp -h, you can see the help:

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.

You must have noticed the description of the -s:filename parameter.

Create a script.txt on the hard disk with the following content:
open
anonymous
user@the.net
cd public
put test.txt
bye

Note: The above is just an example, please modify it according to the actual situation.

Then run the command:
ftp -s:script.txt
Floor3 lxmxn Posted 2006-09-18 04:01
版主 Posts 4,938 Credits 11,386
Hehe, I've always wanted to use a batch script to automatically log in to my FTP, and没想到 it can be done automatically. I agree with the person on the 2nd floor...
Floor4 feitian Posted 2007-05-06 19:19
新手上路 Posts 1 Credits 2
Why did it happen when I followed the above prompts?
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/s for yes/no/quit.
- Use Control-C to abort commands.

You must have noticed the description of the -s:filename parameter.

Create a script.txt on the hard drive with the following content:
open
anonymous
user@the.net
cd public
put test.txt
bye
My FTP server is set up with SERV-U!
Floor5 vkill Posted 2007-05-07 08:32
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023