中国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 11:11
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » [Solved] Seeking a batch script to automatically backup files to FTP
Printable Version  3,029 / 15
Floor1 chainliq Posted 2006-10-30 23:42
高级用户 Posts 244 Credits 635 From 广西贵港
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 ]
Floor2 vkill Posted 2006-10-31 01:09
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
ftp -n -s:test.txt

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

Probably this meaning
Floor3 chainliq Posted 2006-10-31 09:41
高级用户 Posts 244 Credits 635 From 广西贵港
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!
Floor4 redtek Posted 2006-10-31 10:21
金牌会员 Posts 1,147 Credits 2,902
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.



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:

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 ]
Floor5 chainliq Posted 2006-11-05 05:45
高级用户 Posts 244 Credits 635 From 广西贵港
I followed it, and it can connect, but why can't I move and upload files!
Floor6 vkill Posted 2006-11-05 05:52
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
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
Floor7 chainliq Posted 2006-11-05 06:01
高级用户 Posts 244 Credits 635 From 广西贵港
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!
Floor8 vkill Posted 2006-11-05 06:14
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
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
Floor9 redtek Posted 2006-11-05 06:30
金牌会员 Posts 1,147 Credits 2,902
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 should be used in the following way:

(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 ]
Floor10 redtek Posted 2006-11-05 06:37
金牌会员 Posts 1,147 Credits 2,902
Also: What is the EXIT command script you mentioned?



It seems there is no EXIT command in FTP, right?
Floor11 lxmxn Posted 2006-11-05 13:40
版主 Posts 4,938 Credits 11,386
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".
Floor12 chainliq Posted 2006-11-06 23:06
高级用户 Posts 244 Credits 635 From 广西贵港
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?
Floor13 redtek Posted 2006-11-06 23:30
金牌会员 Posts 1,147 Credits 2,902
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:)
Floor14 chainliq Posted 2006-11-06 23:35
高级用户 Posts 244 Credits 635 From 广西贵港
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 ]
Floor15 vkill Posted 2006-11-07 09:21
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Lz主人, pass **** just write **** is enough~ Writing pass is wrong, right!
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023