Reputation: 7197
i got the following batch command
echo 1 & echo 2 1>&2 & echo 3
sometimes this prints 1 2 3 and sometimes 132 how can I control the order? I must have the order.
is there a command that enables the following?
echo 1 & echo 2 1>&2 & flush_stderr() & echo 3
Upvotes: 2
Views: 495
Reputation: 411
If you use &&
instead of &
, it will only proceed to the next command if the previous one completed successfully. In that sense, you can ensure a specific progression.
My belief is that in some cases when you run the line, one of the latter commands completes sooner than an earlier one because they are all initiated at virtually the same time.
Edit: Another solution (albeit more verbose) would be to run a start /wait
for each command.
I.e., start "" /b /wait cmd /c "echo 1" & start "" /b /wait cmd /c "echo 2" 1>&2 & start "" /b /wait cmd /c "echo 3"
Upvotes: 2