Computing.Net > Forums > Programming > Batch: Passing Arguments

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch: Passing Arguments

Reply to Message Icon

Name: squared
Date: May 31, 2005 at 11:41:49 Pacific
OS: XPSP1
CPU/Ram: P4/512
Comment:

Is there a way for batch files to interact with executables? If you run an external program with a batch file, and then it asks for input or for the user to make a selection, can batch files interact this way?

The UNIX analogy that I am more familiar with would be:

program<<eof
input1
input2
input3
eof



Sponsored Link
Ads by Google

Response Number 1
Name: Acyf
Date: May 31, 2005 at 13:43:26 Pacific
Reply:

Depends on the program and how it accepts input. If you are trying to pass parameters to the program like /a or -O then yes you can.... This would be your batch line:

Program input1 input2 input3

type it in the batch file exactly how you would type it out on the command line. Execution will then return to the batch file once your program has finished running. So you could add the line:

ECHO Ok All Done.

After the one above, and it would execute as soon as your program was finished.


0

Response Number 2
Name: squared
Date: May 31, 2005 at 13:58:38 Pacific
Reply:

But that would only work if Program uses variables passed to it at execution. I'm looking to pass information to Program after it has been executed. IE: if at a later point in time, Program were to give the user a prompt requesting a certain type of information, and the user had to manually put that information in.


0

Response Number 3
Name: arul20
Date: May 31, 2005 at 19:28:48 Pacific
Reply:

Nope U cannot. You can only execute commands using DOS. It can't interact with a program. Once DOS calls up the second program, it passes the execution to it and halts.

eg..


DOS
command
command
call Program/batch X <= point Q
command <= point R

After point Q, if the external program finished running and exited, DOS can continue to point R.

However, if, at point Q, the external program asks for some input and pauses .. well .. as far as I know, manual intervention is called for.


0

Response Number 4
Name: squared
Date: June 1, 2005 at 08:50:44 Pacific
Reply:

That's what I was concluding upon. I do it all the time with unix shells, so I figured I was just missing something obvious with batch files, but apparently not. Thanks for the help.


0

Response Number 5
Name: Acyf
Date: June 1, 2005 at 17:26:27 Pacific
Reply:

There is an exception if you are using a program such as osql or ftp which have command line options that will accept commands from a text file.

But it works a little different than what you described, it would be:


ftp -s:script.txt

and script.txt would contain the commands you wanted to execute while running FTP.


0

Related Posts

See More



Response Number 6
Name: dnewsam
Date: June 15, 2005 at 08:57:07 Pacific
Reply:

Hello,

Actually, I was trying to do the same thing. If you have a batch program that asks for user input (ie. y or n), you can do this by putting the y or n into a text file, along with a carriage return. You can then pass the <filename.txt to the command.

Example...

gpupdate /force <N.txt

Where N.txt is a text file in the same directory containing an N and carriage return.

Hope this helps.


David.


0

Sponsored Link
Ads by Google
Reply to Message Icon

from JDK1.4 to JDK1.5 I need the Terminal font!



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch: Passing Arguments

Passing Arguments in C www.computing.net/answers/programming/passing-arguments-in-c/7076.html

Passing argument for Java method. www.computing.net/answers/programming/passing-argument-for-java-method/10374.html

Passing Argument to vbs www.computing.net/answers/programming/passing-argument-to-vbs/17852.html