Click to See Complete Forum and Search --> : How do i run commands on secondary Batch file?


ahsabb
January 26th, 2007, 05:28 AM
I have a batch file application that executes some commands
I need to invoke this batch file by another new batch file and execute the commands related to it.

For Ex:
Calculator.bat : executes command like "mov a, b" .

Now i need to create a batch file that invokes Calculator.bat and executes "mov a, b" command in Calculator.bat

Thanks in advance

alex_gusev
January 26th, 2007, 05:57 AM
if your Calculator.bat executes multiple commands depending on command-line parameters,
all you need to do is just call it from another batch file like this:


call Calculator.bat <your params>


general approach to execute various commands may be as follows:

in your Calculator.bat you write



if "%1x"=="movx" goto MovCmd
...

:MovCmd
<execute it>

ahsabb
January 26th, 2007, 06:19 AM
thanks for the reply Alex,

But the constraint here is that I cannot modify the calculator.bat and also Calculator.bat does not take any parameters

ahsabb
January 26th, 2007, 06:22 AM
FurtherMore the Calculator.bat gives a prompt like
calc>
and waits for the command.I need to give the command for this from my batch file

Thanks

alex_gusev
January 26th, 2007, 06:44 AM
FurtherMore the Calculator.bat gives a prompt like
calc>
and waits for the command.I need to give the command for this from my batch file


may you post some code how is it done in batch file? maybe redirecting input/output is possible there, something like you may call


dir | more

PeejAvery
January 26th, 2007, 10:10 AM
ahsabb, you asked this same question (http://www.codeguru.com/forum/showthread.php?t=412775) yesterday. Please do not post duplicates, it simply floods the forums.

I will have the moderators merge the two threads.

Marc G
January 28th, 2007, 04:23 AM
[ removed duplicate thread in wrong forum ]

PeejAvery
January 28th, 2007, 10:11 AM
[ removed duplicate thread in wrong forum ]
So I will repeat what I said then. A batch file has no parameters so you cannot invoke mov a, b from the batch file. the only thing you can do it run that batch file by using another. That is simply done as you would execute a program.

What you want, cannot be done with batch files.

Marc G
January 29th, 2007, 02:34 PM
So I will repeat what I said then.
Oops, sorry, I removed the thread a bit too fast :blush:
I read the first sentence in your post in the other thread and it said "This is the server-side scripting forum. I will have this moved to Windows OS Issues." and didn't read any further... won't happen again.