Page 1 of 1
Multiple commands per line
Posted: 29 Jul 2008 10:02
by tkhanipov
Hello!
Could you please tell me how to call several commands in one line?
For example, I want to have a single line which will act as the sequence:
echo Bla-bla-bla! Let us call dir?
dir
echo More-bla-bla-bla!
I have no idea of implementing this. Is it possible?
Thanks a lot! It's a very nice and useful site.
Posted: 29 Jul 2008 11:31
by Odder93
EDIT: I can't get example 2 working, but maybe someone know how it works :p
in batch files and in CMD you can use:
Code: Select all
(
<command1>
<command2>
<command3>
<etc.>
)
This will operate each command at nearly same time and output will be showed line by line
in CMD you can also use (If you are lucky it also works in batch files):
Code: Select all
^
<command1>^
<command2>^
<command3>^
<etc>^
<last command>
This will do the same as "(" ")" but will show output on ONE line instead
example 1:
Code: Select all
(
echo blah blah blah... let's jump to root
cd ..
echo blah blah blah...
)
example 2:
Code: Select all
^
echo blah blah blah... let's jump to root^
cd ..^
echo blah blah blah...
Have fun!
Best regards
Odder
Posted: 30 Jul 2008 21:20
by gallennc
If you want to execute this on one line:
echo Bla-bla-bla! Let us call dir?
dir
echo More-bla-bla-bla!
shouldn't it be as simple as:
echo Bla-bla-bla! Let us call dir? & dir & echo More-bla-bla-bla!
works for me.
Posted: 31 Jul 2008 03:32
by Odder93
gallennc wrote:If you want to execute this on one line:
echo Bla-bla-bla! Let us call dir?
dir
echo More-bla-bla-bla!
shouldn't it be as simple as:
echo Bla-bla-bla! Let us call dir? & dir & echo More-bla-bla-bla!
works for me.
ohh, that way
I have read you should use "&" twice, as:
Code: Select all
echo Bla-bla-bla! Let us call dir? && dir && echo More-bla-bla-bla!
But it might work both ways
re
Posted: 31 Jul 2008 07:46
by DGMakers
you can use single & symbols in if's eg:
Code: Select all
if '%var%'=='this' echo lalala & echo Still in the if !!! & echo omg still in there, i think? i think there may be a limit of and symbols but yea & pause & exit
Posted: 17 Aug 2008 18:45
by greenfinch
See
http://technet.microsoft.com/en-us/libr ... 37438.aspx
&& means 'do the next one if the last one completed OK'