Stacking Commands in OS/2

Ever since version One, OS/2 has allowed you to type in multiple commands on the one command line and have the commands execute either all at once or one after the other.

The way to specify two commands that you want to execute at the same time is to separate the commands with an ampersand (&)
eg. copy *.txt f: & copy *.doc f: will copy all files with types txt and doc to your f drive at the same time.

To get two commands to execute in the specified sequence we replace the ampersand with a double ampersand (&&)
eg. c: && cd \temp will change to the c drive and then take you to the temp directory on that drive.

There is even a way to specify a command that will only execute if the previous command failed. To do this you substitute a double vertical bar for the double ampersand (||)
eg. cd \temp || cd \tmp will change the directory to the temp directory (if that directory exists) or the tmp directory (if the temp directory doesn't exist).

So if these characters (&, &&, and ||) have special meanings then what do we do if we just want to place these characters into a command without having the special meaning apply. Well to do this we place what is called an escape character in front of the character to bypass the special meaning and have the character treated as a normal character. With OS/2 this escape character is the caret (^) so when you want to include an ampersand in a command without it having the special meaning described above you just specify it as ^& instead
eg. echo copy ^& delete error.

These joiners are particularly useful in your config.sys file where the commands do not always get executed in the order that they appear in the file. By stacking commands in your config.sys file together using the double ampersand joiner, you can force the commands to execute in the required order.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow