bobobobo
bobobobo

Reputation: 67316

BAT script that sends commands to program it starts

So I'm trying to do something like this:

ftp my.ip.add.ress
(user id)
(password)
cd /the/directory
send C:/code/project1/*
bye

I know you can send Windows ftp commands through the command line when you first start it like -send, but the question is can I use a .bat script to act interactively with the program it starts? By default what happens is the first line:

ftp my.ip

Starts ftp, but the subsequent lines never run until ftp exits.

edit

Another way to phrase this question is "Is it possible to use a .bat file to queue lines of text to feed to stdin when stdin is next checked for input?"

Upvotes: 1

Views: 381

Answers (1)

jball
jball

Reputation: 25024

As far as I know, the command shell is not multi-threaded, so there is no way for a batch to continue executing while another interactive shell program is executing within it.

You need to move the FTP commands into their own file, and pass that to the FTP program so it can run them as its own internal script.

ftp -s:filename

Specifies a text file containing FTP commands; the commands will run automatically after FTP starts.

Upvotes: 2

Related Questions