Volume I:Issue II, Spring 2006
Published: April 1, 2006

In This Issue:
From the Editor: New Print Edition Available!

Developing For Fun With OS/2 And OpenWatcom
--Axel Meiss

Surfing In The Colorful Chinese World With OS/2 And eComStation
--Chen Biao


USB Thumb Drives And Flash Wristbands With eComStation
--Tom Mullins


Power Tips
Gallery-Desktop Backgrounds

Back Issues | Contact eZine | Advertisers
Want to write for OS2eCS eZine-Learn how!






Power Tips

A Powerful Command Line-Stacking Commands
OS/2 and eComStation offers the user a powerful command shell. We are going to explore the various ways to execute multiple commands at the same time. This a useful feature to save time at the command shell and introduce logic into your command scripts (batch files).

Here is how it works:

&
The & character when used between two commands allows both commands to execute unconditionaly without regard to the other.

Example: Lets create a command to backup a file and overwrite the new file. In this example both files will be executed without regard if the other one fails or succeeds.

COPY config.sys config_sys.bak & COPY New_config.sys config.sys


&&
The double && character between two commands are used when you want to execute the second command or program only if the first command executed successfuly. Success is defined by the command or program returning a 0 back to the operating system.

Example: Lets use are same example as above, but this time our command includes logic to only copy over the new file only if the backup was successfully created.

COPY config.sys config_sys.bak && COPY New_config.sys config.sys


||
The two vertical bars provide a way to execute two commands using the logical NOT operator. The second command following the double bars will only execute if the first command was NOT successful. If the command or program returns a value other than zero back to the operating system, then the operation is considered NOT sucessful.

Example: In this example, when the first copy is not successful the user is notified.

COPY config.sys config.bak || echo The file was not backed up successfully

REXX
All the above examples can be incorporated into a REXX script as well. The expression needs to be in quotes as in the following example:

/* Example REXX program to backup config.sys */
'Copy config.sys config_sys.bak && echo Config.sys was backed up successfully'
EXIT


The next time you are at the command shell, remember--You have the power!

[Previous Article] [Contents][Next Article]




OS/2(TM) is a registered trademark of IBM. eComStation(TM) is a registered trademark of Serenity Systems International.
This page viewed 57 times.