• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

how to run list of commands at command line at the same time

Hi,

I have  a list of commands to run (may be around 150). I can run them one by one without any issues. But i want to run them all at once and want to copy the results.

e.g.

collection-admin -m viewcollection -n SCO
collection-admin -m viewcollection -n NHSSLelib
collection-admin -m viewcollection -n NHSDogsPharm
collection-admin -m viewcollection -n Show
collection-admin -m viewcollection -n OnlineBorders
collection-admin -m viewcollection -n carecommission
collection-admin -m viewcollection -n SCCJR
collection-admin -m viewcollection -n NHS24

each single line above is command and shows me result but how can i run all at once?

Thanks
0
mmalik15
Asked:
mmalik15
  • 10
  • 6
  • 3
  • +2
1 Solution
 
John-Charles-HerzbergCommented:
Have you looked into Autoit v3?

How is your review of the credit cards going?  I think we need to make a decision today on what we need to do with the remaining cards.

AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages. AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box.
0
 
Carl TawnSystems and Integration DeveloperCommented:
Easiest way would be just to put them all into a batch file. The you only need to execute the batch file rather than each command individually.
0
 
mmalik15Author Commented:
thanks for the comments. In this case the commands dont have a carriage return

i  have copied pasted the above commads at the DOS  and i only get the result of the last command. e.g.

when i run the following command  i only get the result of


collection-admin -m viewcollection -n SCO
collection-admin -m viewcollection -n NHSSLelib
collection-admin -m viewcollection -n NHSDogsPharm

of this command. which is the last one in the list

collection-admin -m viewcollection -n NHSDogsPharm
0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
mmalik15Author Commented:
I have just created a batch file with the above commands and run it
i am only getting the result of the first command i.e.

collection-admin -m viewcollection -n SCO
0
 
Carl TawnSystems and Integration DeveloperCommented:
If you put all those files in a batch file (say test.bat for example) and then run:
test.bat

Open in new window

From a command line you should see the output of each command. You might have to scroll up the cmd window because it will execute and display the output for each command in turn.
0
 
boing40001Commented:
i think you just copied pasted in the command prompt. you should use a batch file instead like the attached one (rename it bat1.bat before use)

bat1.bat.txt
0
 
boing40001Commented:
i did'nt read your own answer before replying...
do you get any error message from the other commands?
0
 
mmalik15Author Commented:
thanks boing

I have created exactly the same file but i am getting result of the first command :(
0
 
mmalik15Author Commented:
no i dont get any errors. The batch file runs and just returns me the output of the first line
0
 
boing40001Commented:
why don't you add some pause command between lines?
0
 
mmalik15Author Commented:
Tried pause but still no difference
0
 
boing40001Commented:
but afer the first command, it should now pause and tell you something...still no error or something else?
0
 
mmalik15Author Commented:
nothing else this is how i am running batch file(sample file as you attached above) and this is what i am getting

C:\>a.bat

C:\>collection-admin -m viewcollection -n SCO
Name:        SCO
Valid:       yes
Description: http://www.scie-socialcareonline.org.uk/
Cluster:     webcluster
Pipeline:    SCOPipeline (webcluster)
Datasource:  fastuat1.scot.nhs.uk:14000

C:>
0
 
boing40001Commented:
can you try to put the following commands in the batch file and see what happens?

start cmd /k collection-admin -m viewcollection -n SCO
start cmd /k collection-admin -m viewcollection -n NHSSLelib
start cmd /k collection-admin -m viewcollection -n NHSDogsPharm
start cmd /k collection-admin -m viewcollection -n Show
start cmd /k collection-admin -m viewcollection -n OnlineBorders
start cmd /k collection-admin -m viewcollection -n carecommission
start cmd /k collection-admin -m viewcollection -n SCCJR
start cmd /k collection-admin -m viewcollection -n NHS24
0
 
mmalik15Author Commented:
thanks for the comments boing

its running all the commands now but in cascading command line windows i.e. one result per window . Is it possible to get the result in just one window
0
 
boing40001Commented:
usually batch file run commands one line at a time, in only one window. In your case i don't know why this is not happening. the last test i proposed you was just to verify the correct behaviour of batch files in your environment.
I'm going to lunch now :)
0
 
mmalik15Author Commented:
oh okay boing

Enjoy your lunch :)
0
 
John ClaesCommented:
why don't you do the folowing

Create the Batch file of Boing
but add the folowing after every command
>> Output.txt

This will send the output to that Output.txt file

At the end of the batchfile add the folowing lines toprint the output.txt upon the screen
@echo off
for /f "usebackq delims=" %%a in (Output.txt) do (
  echo %%a
)

delete the output.txt
del/Q Output.txt

So it becomes :
start cmd /k collection-admin -m viewcollection -n SCO >> output.txt
start cmd /k collection-admin -m viewcollection -n NHSSLelib  >> output.txt
start cmd /k collection-admin -m viewcollection -n NHSDogsPharm >> output.txt
start cmd /k collection-admin -m viewcollection -n Show >> output.txt
start cmd /k collection-admin -m viewcollection -n OnlineBorders >> output.txt
start cmd /k collection-admin -m viewcollection -n carecommission >> output.txt
start cmd /k collection-admin -m viewcollection -n SCCJR >> output.txt
start cmd /k collection-admin -m viewcollection -n NHS24  >> output.txt
@echo off
for /f "usebackq delims=" %%a in (Output.txt) do (
  echo %%a
)
del/Q Output.txt


regards
poor beggar
0
 
mmalik15Author Commented:
Thanks sir this is i get after making your suggested changes

C:\>a.bat

C:\>start cmd /k collection-admin -m viewcollection -n SCO  1>>output.txt

C:\>start cmd /k collection-admin -m viewcollection -n NHSSLelib  1>>output.txt

The process cannot access the file because it is being used by another process.

C:\>start cmd /k collection-admin -m viewcollection -n NHSDogsPharm  1>>output.t
xt
The process cannot access the file because it is being used by another process.

C:\>start cmd /k collection-admin -m viewcollection -n Show  1>>output.txt
The process cannot access the file because it is being used by another process.

C:\>start cmd /k collection-admin -m viewcollection -n OnlineBorders  1>>output.
txt
The process cannot access the file because it is being used by another process.

C:\>start cmd /k collection-admin -m viewcollection -n carecommission  1>>output
.txt
The process cannot access the file because it is being used by another process.

C:\>start cmd /k collection-admin -m viewcollection -n SCCJR  1>>output.txt
The process cannot access the file because it is being used by another process.

C:\>start cmd /k collection-admin -m viewcollection -n NHS24  1>>output.txt
The process cannot access the file because it is being used by another process.
The system cannot find the file Output.txt.

C:\>
0
 
John ClaesCommented:
some copy paste issues :

I've replaced at my side by the dirs ;-)

should have been :
 
@echo off
start cmd /C "dir c: >> output1.txt"
start cmd /C "dir c: >> output2.txt"
start cmd /c "dir c: >> output3.txt"
start cmd /c "dir c: >> output4.txt"
start cmd /c "dir c: >> output5.txt"
start cmd /c "dir c: >> output6.txt"
start cmd /c "dir c: >> output7.txt"
start cmd /c "dir c: >> output8.txt"
pause



for /f "usebackq delims=" %%a in (Output1.txt) do (
  echo %%a
)
for /f "usebackq delims=" %%a in (Output2.txt) do (
  echo %%a
)
for /f "usebackq delims=" %%a in (Output3.txt) do (
  echo %%a
)
for /f "usebackq delims=" %%a in (Output4.txt) do (
  echo %%a
)
for /f "usebackq delims=" %%a in (Output5.txt) do (
  echo %%a
)
for /f "usebackq delims=" %%a in (Output6.txt) do (
  echo %%a
)
for /f "usebackq delims=" %%a in (Output7.txt) do (
  echo %%a
)
for /f "usebackq delims=" %%a in (Output8.txt) do (
  echo %%a
)
del/Q Output*.txt

Open in new window


the Why's


1) if the command gives a return value the command stops : thats why the normal way doesn't work

2) start cmd / C starts a new command and executes the command
3) using the >> outputX.txt writes the output into the NEW file ==> therefore the numbers  ;-)

4) we must pause until all commands are done to read the files.
5) we cleanup our mess and delete the outputfiles

regards

poor beggar
0
 
mmalik15Author Commented:
Thanks for the detailed explination sir.

Can we not write and append the information into an existing file rather then creating a new file every time as i have hunderds of file and the process wont be very efficent if i create hunderds of dir. or is there a command to close the opened output.txt file so that it gets opened everytime we want to add new text into it.

0
 
John ClaesCommented:
I've done the folowing

I've rerouted all to the output.txt
I've added after every Start line an Choice. This gives the user 0 sec to answer with a X before we give the answer.
This ensures that the program waits before starting the other start (otherwise the overwrite eachother files)

 
@echo off
start cmd /C "dir c: >> output.txt"
Choice /C:x /N /T 0 /D x
cls
start cmd /C "dir c: >> output.txt"
Choice /C:x /N /T 0 /D x
cls
start cmd /c "dir c: >> output.txt"
Choice /C:x /N /T 0 /D x
cls
start cmd /c "dir c: >> output.txt"
Choice /C:x /N /T 0 /D x
cls
start cmd /c "dir c: >> output.txt"
Choice /C:x /N /T 0 /D x
cls
start cmd /c "dir c: >> output.txt"
Choice /C:x /N /T 0 /D x
cls
start cmd /c "dir c: >> output.txt"
Choice /C:x /N /T 0 /D x
cls
start cmd /c "dir c: >> output.txt"
Choice /C:x /N /T 0 /D x
cls

pause

for /f "usebackq delims=" %%a in (Output.txt) do (
  echo %%a
)
del/Q Output*.txt

Open in new window


regards
poor beggar
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 10
  • 6
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now