Mohammed Thabet
Mohammed Thabet

Reputation: 21677

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

Upvotes: 0

Views: 1264

Answers (4)

Mohammed Thabet
Mohammed Thabet

Reputation: 21677

@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

Upvotes: 0

Antoine Pelisse
Antoine Pelisse

Reputation: 13109

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.

Upvotes: 0

Albin Sunnanbo
Albin Sunnanbo

Reputation: 47048

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.

Upvotes: 1

D&#39;Arcy Rittich
D&#39;Arcy Rittich

Reputation: 171451

Use a CRLF between each command.

Upvotes: 0

Related Questions