开发者

How to write sequential commands in batch file

I want ot execute 开发者_如何学编程the following commands using batch file:

1.ftp 127.0.0.1 
2.USERNAME
3.PASSWORD 
4.put
5.D:\\zz.xml
6.mmm.xml 

Each command is a sequence of the prev command

I want to move file from local to ftp server

I googled for that and I found that insert ; between commands is the solution but itsn't correct for me

Please support me


1 is a command on the command prompt, but 2..6 are FTP commands.

I would put lines 2..6 in a file called commands.txt then redirect that file to stdin.

ftp 127.0.0.1 < commands.txt

Edit:
You could use -s:commands.txt instead of the < according to the ftp help.

-s:filename Specifies a text file containing FTP commands; the
commands will automatically run after FTP starts.


Use a CRLF between each command.


I would rather use the expect command that allows you to script inputs according to outputs. You can find some information here: http://en.wikipedia.org/wiki/Expect

You have an example on that page that describes exactly what you want to do.


@Albin Sunnanbo

Thanks for your reply

I solved the problem now from the following tutorial http://www.dostips.com/DtTipsFtpBatchScript.php

I write the foillowing commnads in batch file:

FTP -v -i -s:commands.txt

then commands.txt contaisn the following commands

open 127.0.0.1 
UserName
Password
put
D:\\zz.xml
mmm.xml
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜