Conditional Execution

Syntax

if command1 succeeds then execute command2 (IF)

command1 && command2

Execute command1 and then execute command2 (AND)

command1 & command2

Execute command2 only if command1 fails (OR)

command1 || command2

Care must be taken in using this syntax to read and SET variables as by default variables are expanded one line at a time.

Success is defined as returning an %errorlevel% = 0

Example

   COPY H:\share\TNSnames.ora C:\Oracle\ || ECHO The Copy Failed

“Conditional cooperation is like adulterated cement which does not bind” ~ Mohandas K. Gandhi

Related:

IF - Conditionally perform a command.
Command redirection



Back to the Top

© Copyright SS64.com 1999-2013
Some rights reserved