Next Meeting: Sat, TBD
Meeting Directions

Be a Member


Help with Searching

20 Most Recent Documents
Search Archives
Index by date, title, author, category.


Mr. Know-It-All



Email Lists

SIGs (Internet, General Interest, Programming, Network, more..)

Online Chats


Past Presentations



Contact SCOUG

Copyright SCOUG

warp expowest
Pictures from Sept. 1999

The views expressed in articles on this site are those of their authors.

SCOUG was there!

Copyright 1998-2024, Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.

The Southern California OS/2 User Group

SCOUG OS/2 For You - June 1993

The OS/2 Command Line

by Michael Lavender

There are some exceptional features to the OS/2 command line. Some of these features have been co-opted by DOS (starting, in a limited way with MS-DOS 5.0). I've never dealt with the DOS use of these features, so bear with me if I talk about ho-hum, seen-it-all-before sort of things.

The first time I used an OS/2 window, I discovered F1 and F3 do not work. That drove me back to a DOS window, but my fears were assuaged as those most used keys do their most used job in the DOS shells. For nearly a year I let the matter drop, but as I learned more about OS/2, the more interesting were the possibilities inherent in OS/2 shells.

Let's start with the DOSKEY-like features. In the CONFIG.SYS file, there is a line with the words SET KEYS=ON. This is set up by the installation of OS/2. It allows up to 64KB for storing previous commands in a command line session. To access these commands, press the up or down arrow key. Each press will bring up an earlier command typed in that session. You can then edit that command in standard word processing fashion: the right or left arrow will move through the command one character at a time, and the Ctrl-right or left arrow will move the cursor from word to word. Home will bring you to the start of the command, and End will bring you to the end. Esc will clear the line.

If the cursor is an underline, the edit mode is overwrite (what you type replaces the text). Pressing the Ins (insert) key will change the cursor to a small flashing rectangle. This allows you to insert characters into the command line. Del deletes the character the cursor is on; Backspace deletes the character to the left of the cursor. Now we get to the fun stuff: Ctrl- End deletes the command from the cursor to the end of the line and Ctrl-Home deletes the line from the start to the cursor.

You can make a list of the commands used in the session by typing in KEYS=LIST. You can always mark that list (assuming you're in a window session) and copy it to a text editor as the beginnings of a batch file. Oh, yeah, there's a downside to all this. KEYS=ON removes ANSI.SYS support. (You still have it in DOS sessions.) Since I never did know what was in ANSI anyway, its loss is meaningless to me.

OS/2's commands have some expansions when compared to DOS. A command that does not require a second parameter (COPY is an example that needs two parameters) can have as many parameters as can fit on the line. Example: suppose you wanted to create a number of sub-directories. The command


etc. is perfectly acceptable. You can also stack commands by placing an ampersand (&) between them, such as C: &CD\WINDOWS, changing the drive and the directory in the same line. Pipes and redirection (|, <, >, and >>) work the same as they do in DOS.

There is conditional stacking in OS/2. One ampersand will start two commands unconditionally, two limits the execution of the second command upon the successful completion of the first. So let's check it out.

This example requires some work on the reader's part. Start an OS/2 window. Find a directory with .BAK files (create some yourself if you have to). Now, type the following command:


Press enter. Now press the up arrow key to replace the command. Press enter again. You should see one error message. Now press the up arrow key to replace the command a third time. This time edit it to this:


Press enter. You will see two error messages. The conditional symbol || runs the second command if the first fails. The second time you ran this command, the system looked but couldn't find any .BAK files so didn't try to delete them. The third time, with the symbol ||, the system couldn't find the files, but tried to delete them anyway.

You can put commands in parentheses in much the same fashion as you would in mathematical equations, to have them done as a group. Using OS/2 2.1 Unleashed examples we see:


creates a file with a sorted CONFIG.SYS, assuming it is in the directory, whereas


creates a file with the directory listing of CONFIG.SYS, as well as the sorted file.

Multitasking is also possible through the command line. START and DETACH begin new processes in OS/2. Without using either of these two commands, the command session is a single threaded process. Starting a program in the command shell makes the shell disappear, to be replaced with the program. If you type in START program name, the program will start in another window, with the command shell still running. DETACH runs a program in a separate thread invisible to the user (no window, no listing in the Task List, etc.). DETACH returns a processor ID, allowing you to track and control the program (assuming you have programs that allow such control).

Most books out in the market suggest you use DETACH with caution, and only with programs that do not need user input. I agree with the first, but redirection allows a little amount of interaction with both DOS batch files and DETACHed programs. In a batch file book, I learned that you could create a text file with the required keystrokes for a program, and then run the program with the text file as the redirected input. An example would be a file with just the letter Y and the enter key. I created the file as ENTERY and then created a temporary directory with the contents of another directory. I entered into the temporary directory, typed


and the directory was emptied through an underground process.

Everything talked about here can be used in the command line directly, or in a batch file, whether written like a DOS batch file, or in REXX. Rewrite the batch files you already have. Determine what sections must be run after other sections and put them in the same thread. Combine lines with the &&or || features. Homemade multitasking and multithreading: The possibilities are endless.

The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA

Copyright 1994 the Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG is a trademark of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation.
All other trademarks remain the property of their respective owners.