Stupid OS/2 Tricks/Command Line Tips

Return to OS/2 Stupid Tricks Main Page

This section covers tips and tricks which affect command line sessions.

Pasting text without the final carriage return
To paste text after a copy/mark operation without a final carriage return, hold down the Shift key while choosing Paste from the pull-down menu.

Clearing the Delete subdirectory
In order to remove the files from the Delete subdirectory of a drive to regain some drive space, type the following at a command line: UNDELETE :\* /f /s /a where is the letter of the drive which contains the Delete subdirectory you wish to clear.

Related subject(s):
 * Permanently deleting a file when Undelete is active

Searching for file names
To search for a particular file name on a drive, type DIR :\ /S where
 * is the letter of the drive you wish to search
 * is the specification of the file you are searching;

standard wild cards can be used.

Maximizing windows when opening
To make all command line windows open maximized, hold the Shift key while clicking on the maximize button.

Note: the above procedure causes anomalous behavior (the window opens in the upper left hand corner, then repositions itself in the middle of the screen) under the 2.11 CSD. To fix this problem, hold the Shift key while clicking on the restore button in the uppermost right hand corner of the command line window.

In some cases, you additionally may have to hold the Shift key while using the mouse to resize the window to its fullest size by dragging the bottom right corner.

Related subject(s):
 * Resizing a command line window permanently

Creating a scroll buffer
from Tim Sipples' FAQ

To create a small scroll-back buffer for your command line sessions, type MODE 80,102

Related subject(s):
 * Resizing a command line window permanently

Using OS/2 without the Workplace Shell
To use OS/2 without loading the Workplace Shell, replace the following line in your CONFIG.SYS SET RUNWORKPLACE= :\OS2\PMSHELL.EXE with SET RUNWORKPLACE= :\OS2\CMD.EXE where is the letter of the drive on which OS/2 is located.

Note that you can always invoke the Workplace Shell by typing PMSHELL at an OS/2 command line. It can consequently be removed by closing it from the Window List.

Related subject(s):
 * Booting OS/2 in full-screen mode

Enhancing speed of text scrolling
Tricks for speeding up text display.

Changing font size
Fonts which are 8 pixels wide generally display faster than those which are not 8 pixels wide. Choose Font Size from the pull-down menu, then choose a "x 8" type of font size.

Changing Video_ROM_Emulation
Text scrolling speed can also be enhanced using the Video_ROM_Emulation setting.
 * 1) Select DOS Settings from either the pull-down menu of a DOS session, or from the Session page of the Settings notebook of a DOS session.
 * 2) Highlight Video_ROM_Emulation.
 * 3) Try the setting both on and off to find out if one setting results in better performance than the other.

Adding entries to your PATH
You can add entries to your PATH "on the fly" by using: PATH %PATH%; :\ where
 * is the drive on which the subdirectory you want to add is located
 * is the path you want to add

Note: This also works for DPATH

Permanently deleting a file when Undelete is active
If you have Undelete activated (via SET DELDIR in your CONFIG.SYS), but want to delete a file or files so they can't be undeleted, use: DEL  /F where  is the file specification of the file(s) you want to delete.

Related subject(s):
 * Clearing the Delete subdirectory

Suppressing echo from *.CMD files
If you are using batch files (*.CMD) which do not have ECHO OFF statements, you can also suppress the echo by using the /Q switch:

Example: BATCH.CMD /Q

Getting more out of your command line
contributed by Jack Tan

Supplement your command line usage by stacking commands with &&, &, ||, and : (Else.EXE doesn't run if and only if both If.EXE and Then.EXE run successfully) (the commands in parentheses are operated on by DETACH, then UNZIP executes)
 * && executes the second program only if the former succeeds, e.g., RunMe.EXE && RunMeIfFormerSucceeds.EXE
 * || executes the second program if the former doesn't succeed, e.g., RunMe.EXE || RunMeIfTheFormerDidntSucceed.EXE
 * Combining && and || results in an if..then..else situation, e.g., If.EXE && Then.EXE || Else.EXE
 * & runs both the first and second programs, e.g., RunMe.EXE & AndMeToo.EXE
 * executes the instructions within the parentheses, overriding the normal order of command precedence, e.g., DETACH (FORMAT a: /once /v:"hi" && XCOPY c:\x A: /S) & UNZIP file.zip

Checking drive status
Inspired by a code snippet by Dick Goran

You can check the status of a drive, e.g., if a floppy is inserted into a floppy drive or not with a REXX script, CHKDRIVE.CMD

The routines in CHKDRIVE.CMD can be incorporated into longer REXX scripts whenever the status of a drive needs to be ascertained.

Other REXX scripts:
 * OPEN.CMD
 * BITMAP.CMD
 * SETPTR.CMD
 * SETFONT.CMD
 * SHUTDOWN.CMD
 * SHREDDER.CMD
 * SLEEP.CMD
 * LARGE.CMD
 * EVAL.CMD
 * BIGDOS.CMD
 * PUTLONG.CMD

Shutting down from a REXX script automatically
by David Matocha

You can shutdown your system with a countdown using SHUTDOWN.CMD combined with a scheduling utility and a automatic power-down of the system.

Related subject(s):
 * Rebooting from the command line
 * OPEN.CMD
 * BITMAP.CMD
 * SETPTR.CMD
 * SETFONT.CMD
 * CHKDRIVE.CMD
 * SHREDDER.CMD
 * SLEEP.CMD
 * LARGE.CMD
 * EVAL.CMD
 * BIGDOS.CMD
 * PUTLONG.CMD

Using multiple arguments at the OS/2 command line
Unlike DOS, OS/2's command line allows you to use multiple arguments at the command line for the DEL and DIR commands.

e.g., DEL DIR

where, , and are different filenames (with any appropriate wildcards).

Using EPM as a customized command shell
contributed by Jack Tan Use the Enhanced Editor (EPM) command SHELL to produce a command line with the following attributes:
 * Uses any font recognized by EPM.
 * Window sizeable to nearly any size.
 * Dynamically resizeable window.
 * Can alter text/background colors.
 * Scroll buffer spans the entire session.

Unfortunately, programs which take control of the screen (like screen-based editors) won't run.

Setting the startup directory for command line objects
contributed by Jack Tan

The 'Working Directory' entry in the settings notebook also applies to command lines, such as 'OS/2 Window' and 'DOS Full Screen.' In these cases, the working directory becomes the starting directory.

Formatting a diskette with the detach command
You can format a diskette in the background from the command line or in a batch file without user intervention with the line: DETACH FORMAT : /ONCE /V: where is the drive of the diskette you wish to format, and is the name you wish to use for the volume label.

Resizing a command line window permanently
contributed by Guy Gerard Lemieux

You can save the size of any window permanently by holding the Shift key while resizing.

Related subject(s):
 * Maximizing windows when opening
 * Creating a scroll buffer

Making the system "sleep"
The REXX script SLEEP.CMD will create a pause for a specified length of time.

Other REXX scripts:
 * OPEN.CMD
 * BITMAP.CMD
 * SETPTR.CMD
 * SETFONT.CMD
 * CHKDRIVE.CMD
 * SHUTDOWN.CMD
 * SHREDDER.CMD
 * LARGE.CMD
 * EVAL.CMD
 * BIGDOS.CMD
 * PUTLONG.CMD

Substituting REPLACE for the COPY command
The REPLACE command will only copy files of the same name from the source to the target: REPLACE where is the drive, path, and file specification of the files you want copied; and, is the drive and path to which you want the files copied.

However, when REPLACE is used with certain command line switches, it becomes even more useful.

Have you ever wished you could only copy files which don't already exist on the target drive? Try: REPLACE /A Have you wanted to copy only files which have been updated? Try: REPLACE /U

"Touching" a file's date and time
You can "touch," i.e., change to current date and time, a file or set of files using a form of the COPY command: COPY /b + ,, where is any valid filename or OS/2 file specification

Adding command sessions to the desktop's popup menu
When adding OS/2 or DOS command line sessions to the desktop's popup menu, prevent the object from passing the desktop's path by putting a percent sign (%) in the Parameters field on the Program page of the command line object's Settings notebook.

Related subject(s):
 * Adding an "open folder" entry to the desktop's popup menu
 * Opening multiple command line sessions from the desktop menu
 * Adding INF files to the desktop popup menu

Opening multiple command line sessions from the desktop menu
In order to be able to open multiple command line sessions from a command line object that you added to the desktop's popup menu, you must alter the desktop's settings, not those of the command line object:
 * 1) Open the Settings notebook for the desktop.
 * 2) Choose the Window tab.
 * 3) Under Object Open Behavior, select Create New Window.
 * 4) Close the Settings notebook.

Note: changing the Object Open Behavior for the desktop may have unexpected results when opening other objects from the desktop.

Related subject(s):
 * Adding an "open folder" entry to the desktop's popup menu
 * Adding command sessions to the desktop's popup menu

Creating a command line calculator
contributed by L. Kuru

EVAL.CMD is a REXX script for a simple, yet powerful command line calculator.

Several arithmetic functions are available: set radius=3 EVAL %pi%*%radius%**2
 * The basic arithmetic functions:
 * + = Addition
 * - = Subtraction
 * * = Multiplication
 * / = Division
 * ** = Exponential (must be an integer)
 * Parentheses, e.g., EVAL (2+3)**2
 * Floating point numbers, e.g., EVAL 12.345567e14*1e-50
 * Environment variables, e.g., set pi=3.1415926

Other REXX scripts:
 * OPEN.CMD
 * BITMAP.CMD
 * SETPTR.CMD
 * SETFONT.CMD
 * CHKDRIVE.CMD
 * SHUTDOWN.CMD
 * SHREDDER.CMD
 * SLEEP.CMD
 * LARGE.CMD
 * BIGDOS.CMD
 * PUTLONG.CMD

Starting a DOS session with maximum free memory
contributed by Xavier Caballe

You can start a DOS session with the maximum free memory using BIGDOS.CMD.

Note: if using OS/2 2.1, you may have to change RMSIZE=640 to RMSIZE=639 in your CONFIG.SYS file in order to get this to work.

Other REXX scripts:
 * OPEN.CMD
 * BITMAP.CMD
 * SETPTR.CMD
 * SETFONT.CMD
 * CHKDRIVE.CMD
 * SHUTDOWN.CMD
 * SHREDDER.CMD
 * SLEEP.CMD
 * LARGE.CMD
 * EVAL.CMD
 * PUTLONG.CMD

Using START to avoid the dreaded "clock".
contributed by Jack Tan

Use the START command in a fullscreen session to avoid the dreaded clock pointer and continue working at the command line when loading certain queue-hogging applications.

e.g, at a fullscreen OS/2 prompt: START /b 123G.EXE

Coloring OS/2 command line sessions
contributed by Peder Madsen

Tired of the dreaded black-and-white OS/2 command prompt? Create more colorful prompts with the PROMPT command. Try: set prompt=$E[37;44m[$P]

which gives you white text on blue background.

Instead of 37 you can use any number between 30 and 37 to control the foreground color, and instead of 44 you can use any number between 40 and 47 to control the background color.

You can also use the PROMPT command in your CONFIG.SYS file to start each OS/2 command session with your favorite colors.

Note: ANSI must be turned on (this is the default).

Copying fullscreen text to the Clipboard
contributed by Hugo Jimenez-Vazquez

To copy fullscreen text to the OS/2 Clipboard:
 * 1) Open the menu for the default printer and change the status of the jobs to "Hold."
 * 2) Go to the OS/2 fullscreen session you wish to copy, and press the PrintScreen button on your keyboard.
 * 3) Go back to the OS/2 desktop and open either the Icon or Details view of the default printer.
 * 4) Double click on the icon of the PrintScreen job. This will place the job into the OS/2 System Editor (E.EXE).
 * 5) Copy the desired text from the OS/2 System Editor to the OS/2 Clipboard.
 * 6) Delete the job from the list of the default printer.
 * 7) Change the status of the default printer back to "Release."

Displaying custom DOS settings at the command line
contributed by Jack Tan

To list custom DOS settings (i.e., the settings which have been changed from the default) at the command line:


 * 1) Open the Settings notebook for the DOS program object.
 * 2) Put an asterisk (*) as the first character in the "Path and File Name" box on the Program page. If the filename is already an asterisk, place some text immediately after the asterisk.
 * 3) The icon will change to that of an OS/2 window after the change.
 * 4) Open the session by clicking on its icon. This should bring up an OS/2 command line window.
 * 5) Type "SET" (without quotes) at the command line.
 * 6) This should list the customized DOS settings, as well as some environmental variables.
 * 7) When done, remove the asterisk or extra text from the Settings notebook.
 * 8) If the DOS session was fullscreen initially, it may be changed to a windowed session. If so, click on the Session tab, and choose "DOS full screen."

Using PMREXX as a scrolling command window
contributed by Michael Prager

Many of us have wished for a scrolling command window, as supplied in many graphical versions of Unix. This is how to get one. At an OS/2 command line, type: PMREXX REXXTRY.CMD This gives a scrolling Rexx window that executes Rexx commands interactively. Since Rexx passes through all OS/2 commands, it can be used for executing OS/2 commands. Just don't forget that many OS/2 commands will need to be enclosed in quotation marks. //

Related subjects:
 * Using EPM as a customized command shell

Switching temporarily to a different directory
contributed by Jack Tan

To switch temporarily to a different directory when at an OS/2 command line, type CMD.EXE at the command line. Switch to the directory you want, and when you are finished in that directory, simply type EXIT at the prompt. You will be back in your original directory.

Canceling print jobs from the command line
contributed by Jack Tan

You can use command line switches to cancel print jobs from the OS/2 command line: PRINT /C will cancel the current print job on the default printing device. PRINT /T will cancel the current print job and the rest of the print queue on the default printing device.

If you want to cancel a job on a device other than the default, add the switch /D: where is the name of the print device (e.g., LPT2).