China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-04 10:09
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Solved] Seeking a batch script to automatically backup files to FTP View 3,023 Replies 15
Original Poster Posted 2006-10-30 23:42 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
Got an idea, maybe my this idea has been asked by N people before, but I still don't understand now.
Want to ask you all for advice:
On 2003 FTP, I want to make a batch processing in the scheduled task of the charging system. When running the batch processing, it can automatically log in to the FTP and copy the local D:\1234 to D:\Backup on the FTP. I have tried many parameters, but it doesn't work, I don't know why.

Hahaha, I seem to become a problem king, almost have problems every day, really sorry!

[ Last edited by chainliq on 2006-11-6 at 11:36 PM ]
Floor 2 Posted 2006-10-31 01:09 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
ftp -n -s:test.txt

test.txt
o 127.0.0.1 21
user admin
pass
put D:\1234\*.*
exit

Probably this meaning
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +2 2006-10-31 10:25
Floor 3 Posted 2006-10-31 09:41 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
Originally posted by he200377 at 2006-10-31 01:09:
ftp -n -s:test.txt

test.txt
o 127.0.0.1 21
user admin
pass
put D:\1234\*.*
exit

Roughly this meaning


You mean to say to write
o 127.0.0.1 21
user admin
pass
put D:\1234\*.*
exit
into a test notepad, save it as test.txt
Then call: ftp -n -s:test.txt?
Then where is the test.txt stored!
Please advise!
Floor 4 Posted 2006-10-31 10:21 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
The meaning of ftp -n -s:test.txt is: the commands you need to type in ftp are placed in a script file, named test.txt.
The parameter -s: means that the following is the specified script command file with automatic commands.

For more detailed information, you can look at its help. You can view the help information by FTP --help, while FTP /? will not show the help.
The acquisition of help information by FTP --HELP, this --HELP instead of /? comes from the Linux style, and the usage is the same there.


C:\windows\system32>ftp --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.


Since FTP will call the automatic command script file specified by you through the -s: parameter as soon as it runs,
then this test.txt must be in the current directory.


Why the content of test.txt is like this:

o 127.0.0.1 21
user admin
pass
put D:\1234\*.*
exit

Because if you directly enter FTP, you also need to tell it which server you want to connect to first?
So the command is:
open the server address you want to connect to 21

This 21 is the port number of the server you want to specify for connection (it is generally 21 by default, if it is not 21, it is generally for special reasons such as preventing hacker scanning...).

Then the service is connected,
naturally you need to enter the login name and password,
so, if you operate in FTP yourself, remember what commands you have used,
you can write a command set for this "answer" command to execute automatically, put it in a text file,
and then operate as in the example principle of he200377.

Enter FTP, if you type?, you can also get more detailed command help.
         

As for which operation commands are placed in your automatic response instruction file (test.txt),
you need to first use ftp to perform all the work operations you need,
so you will know what the system will ask you, and then what content you need to enter (this input is what should be put into the automatic instruction set file).

[ Last edited by redtek on 2006-10-31 at 10:24 AM ]
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 5 Posted 2006-11-05 05:45 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
I followed it, and it can connect, but why can't I move and upload files!
Floor 6 Posted 2006-11-05 05:52 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by chainliq at 2006-11-5 05:45:
I followed the steps, and it can connect, but why can't I move and upload files!

Uploading can't use *.*~ You need to write the complete local path
Floor 7 Posted 2006-11-05 06:01 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
I wrote it, but it was still uploaded. But when I use put in CMD, it works. However, the following method:

ftp -n -s:test.txt

The content of test.txt is:
o 192.168.2.248 21
user ****
pass ****
cd MYDOS
put d:\New Folder\98765432.txt
exit
by

But it just can't be uploaded. I don't know why!

But this way can be:

Run -cmd
Enter FTP IP
Then enter username and password
Put d:\New Folder\98765432.txt
by

This can be:

Run -cmd
Enter FTP IP
Enter username and password
Put d:\New Folder\98765432.txt
by

I don't know why! But this way works:

Run -cmd
Enter FTP IP
Enter username and password
Put d:\New Folder\98765432.txt
by

I don't know why! But when I do it like this:

Run -cmd
Type FTP IP
Type username and password
Put d:\New Folder\98765432.txt
by

It works. I don't know why the first method doesn't work but the second does!
Floor 8 Posted 2006-11-05 06:14 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by chainliq at 2006-11-5 06:01:
Wrote it, but it was still uploaded. But I can use put in CMD, while the method you mentioned:

ftp -n -s:test.txt

The content of test.txt is:
o 192.168.2.248 21
user ****
pass ****
cd MYDOS
put d:\新堮..

The rest is for you to figure out slowly~ No one knows every problem
Floor 9 Posted 2006-11-05 06:30 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
After testing, there is no problem here. At the same time, I simulated your directory location: D:\New Folder\98765432.txt to prevent the extremely unlikely one in ten thousand error...

Test FTP server type: Linux host

Your test.txt command file is as follows:
(Note: Do not add the commands user or pass in front of the login name or password, just write the login name or password directly.)
(If your login name is abc, then write abc...)

Your FTP login name
Your FTP login password
cd mydos
put d:\New Folder\98765432.txt
by



Your FTP should be used in the following way:

FTP.EXE -S:test.txt 192.168.2.248

(That is: directly specify the command file test.txt and then directly specify the server address to log in.)


Then try again, it should be no problem.
Even if there is a problem, it's okay, just look at the error message (if you are familiar with all FTP commands).

[ Last edited by redtek on 2006-11-5 at 06:34 AM ]
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 10 Posted 2006-11-05 06:37 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Also: What is the EXIT command script you mentioned?


C:\WINDOWS>ftp
ftp> he
Commands may be abbreviated. Commands are:

! delete literal prompt send
? debug ls put status
append dir mdelete pwd trace
ascii disconnect mdir quit type
bell get mget quote user
binary glob mkdir recv verbose
bye hash mls remotehelp
cd help mput rename
close lcd open rmdir


It seems there is no EXIT command in FTP, right?
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 11 Posted 2006-11-05 13:40 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Originally posted by chainliq at 2006-11-5 06:01:
I wrote it, but it was still uploaded. But I can use put in CMD, while the method you mentioned:

ftp -n -s:test.txt

The content of test.txt is:
o 192.168.2.248 21
user ****
pass ****
cd MYDOS
put d:\新堮..

  The problem is very likely in the content of your test.txt.

  You have used "o 192.168.2.248 21", then you can directly connect with the username and password below, and there is no need to add "user ""pass " in front. Moreover, in ftp, logging out is using "bye", not "exit".
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +2 2006-11-05 20:08
Floor 12 Posted 2006-11-06 23:06 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
I see, there's an error prompt "Not connected" appearing after entering the username. This means there's no connection or no sharing. How to solve it?
Floor 13 Posted 2006-11-06 23:30 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Didn't I give the楼主 practical examples?
Moreover, regarding the setup of the FTP server... I don't know if the楼主 is very familiar with the basic correct operations of FTP commands? (But the examples above have been very clearly given:)

At the same time, I don't know if the楼主 can correctly judge whether the FTP server or due to the reason of the firewall, you can't access the server correctly, and whether the port is enabled, etc.?

(If the楼主 can't judge, please give detailed steps of your operation)
(Actually, the examples given by the upstairs are already very clear:)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 14 Posted 2006-11-06 23:35 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
Haha, solved it, hehe, didn't expect that changing a method would KO it````! Still need to use your brain!
o 192.168.2.248 21
user gg123 ********
cd MYDOS
put ``````````

Thanks for everyone's help呀!!

[ Last edited by chainliq on 2006-11-7 at 10:52 PM ]
Floor 15 Posted 2006-11-07 09:21 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Lz主人, pass **** just write **** is enough~ Writing pass is wrong, right!
Forum Jump: