home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
WAIT.ZIP
/
WAIT.DOC
< prev
next >
Wrap
Text File
|
1991-02-06
|
15KB
|
374 lines
WAIT 1.10
OS/2 "WAIT" UTILITY
WAIT is a general purpose OS/2 "wait" or "wait until" utility.
Using WAIT, you can wait for a specified period of time, until a
specified time, or until a specified process has ended. When
the waiting period has ended, WAIT can execute any OS/2 command,
program or batch file (including starting a new session or
detaching a process); or, it can simply terminate. WAIT uses
very little of your system's resources while it is waiting, so
other processes can run quite efficiently.
Usage summary
-------------
There are several ways to use WAIT:
WAIT [/D] elapsed-time [command {arguments}]
WAIT [/D] UNTIL [date|TOMORROW] time [command {arguments}]
WAIT [/D] FOR name [command {arguments}]
WAIT [/D] FOR PID # [command {arguments}]
WAIT [/D] FOR SESSION # [command {arguments}]
WAIT /V
WAIT /HELP
The arguments must be entered in the order specified but are not
case-sensitive. You may use either '/' or '-' to introduce
option switches.
Waiting for a specified period of time
--------------------------------------
The first format is used to wait for a specified period of time:
WAIT [/D] elapsed-time [command {arguments}]
The period of time can be specified as any of:
hh:mm:ss
hh:mm
hh:
:mm:ss
:mm
Missing elements are assumed to be 0; thus, "12:15" is assumed
to mean "12:15:00", or twelve hours and fifteen minutes.
Without the /D option, WAIT executes the child process using the
current command shell (usually CMD.EXE); the child process cna
thus be any valid OS/2 internal command, batch file, or program
name. If no command is specified, WAIT simply terminates when
the time has elapsed.
If command arguments require special characters (like
redirection characters), you can pass them intact to WAIT by
enclosing them in quotes. You can either quote the special
characters themselves or the entire argument string; just don't
quote the command itself:
wait :10 dir "> prn" (OK)
wait :10 dir ">" prn (OK)
wait :10 "dir prn" (WRONG - don't quote the command)
wait :10 dir > prn (WRONG - output from WAIT, not
DIR, is redirected)
If you need to pass along a real quotation mark, use double
apostrophes:
start ''session name'' my prog
Examples:
wait 1:0:0
Wait one hour, then terminate.
wait :10 dir
Wait ten minutes, then execute a DIR command.
wait 196: dir "> prn"
Wait 196 hours, then execute a DIR command, redirecting
output to the printer. Quotes are required, otherwise
WAIT's output will be routed to the printer.
wait :0:15 start "''New Session'' /fs c:\cm\rxt2.exe > nul"
Wait fifteen seconds, then start a new session as
shown. Note that ''New Session'' is translated to
"New Session" as required by the START command.
With the /D option, WAIT executes the program directly, without
using the command shell (this is equivalent START's /D option).
This is faster but more limited; the command to be executed must
be an external program (not an internal command or batch file),
and you cannot use redirection. The other advantage to using /D
is that you will receive the exit code of the specified program,
rather than the exit code from the command shell.
Examples:
wait /d :10 rxt2 arg1 arg2
Wait ten minutes, then execute RXT2.EXE with arguments
as specified. RXT2.EXE may be in the current directory
or anywhere in the current PATH.
wait /d :10 dir
Invalid: internal commands not legal with /D.
wait /d :10 foo "> prn"
Invalid: cannot use redirection.
Waiting until a specific date/time
----------------------------------
The second format is used to wait until a specified time:
WAIT [/D] UNTIL [date|TOMORROW] time [command {arguments}]
The optional date may be specified as either of:
mm/dd/yy
mm/dd (assumed current year)
If a date is specified, the keyword UNTIL is assumed (and
is therefore optional). If no date is specified, the current
date is assumed, and the keyword UNTIL is required.
The time may be specified as any of:
hh:mm:ss
hh:mm (ss assumed 0)
hh: (mm, ss assumed 0)
:mm:ss (hh assumed current hour)
:mm (hh assumed current hour, ss assumed 0)
Hours are assumed to be in 24-hour format:
11:15 (11:15 am)
23:15 (11:15 pm)
The remaining arguments are used exactly as described in the
last section. Examples:
wait until 11:15
Wait until 11:15 am, then terminate.
wait until 1/12 11:15
Wait until 11:15 am on January 12, then terminate. Note
that the UNTIL keyword is optional here.
wait until 11:15 detach "dir > prn"
Wait until 11:15, then send a directory listing to the
printer, detaching this as a separate process.
wait /d 2/14 11:15 rxt2 "arg1 arg2"
Wait until 11:15 on 2/14, then run RXT2.EXE directly.
If the specified time has already passed when WAIT begins, then
WAIT will either terminate or run the specified command
immediately (as appropriate). There is, however, one exception
to this. If:
-- no date is specified, and
-- the current time is 10pm (22:00) or LATER, and
-- the specified time is 10am (10:00) or EARLIER,
then WAIT assumes that you mean "tomorrow morning" rather than
"this morning". This allows you to start overnight processing
before midnight without having to specify a date. For example,
if it is now 11:00pm and you type
wait until 03:00 command
then WAIT assumes you mean 3am tomorrow, rather than 3am today
(which has already passed).
You can also use the keyword TOMORROW to indicate that you mean
tomorrow's date rather than today. This is useful if you want
to start an overnight process before 10pm:
wait until tomorrow 03:00 command
Waiting for a process or session to end
---------------------------------------
These three formats allow you to wait for a specific process or
session to end:
WAIT [/D] FOR PID # [command {arguments}]
WAIT [/D] FOR name [command {arguments}]
WAIT [/D] FOR SESSION # [command {arguments}]
The keyword FOR is required; this is what signals WAIT that you
want to wait for a process or session (rather than a time).
A process can be specified either by a process ID number or by
name. Process ID numbers can be in decimal (default) or in
hexadecimal (preceded by 'x'). Use the keyword PID to indicate
that you're specifying a process ID number. For example:
wait for pid 90 "dir > prn"
Wait for process 90 to terminate, then run DIR
wait /d for pid 0x5A "dir"
Wait for process x5A (decimal 90)
To specify a name, just omit the PID keyword and use the name:
wait /d for RXT2 "prexx msgscan"
Wait for "RXT2" to end, then run "prexx msgscan".
To specify a session, use the session number in either hex or
decimal:
wait for session 12 "prexx msgscan"
wait for session x0c "prexx msgscan"
"Waiting for a session" means waiting for all processes with the
specified session ID to terminate.
Notes:
1. You can see a list of process names and numbers with the
OS/2 programs PS or PSTAT, with the supplied program PLIST,
or with the public domain programs STATUS or RUNNING.
PSTAT, STATUS, and RUNNING all display more information than
PLIST. However, PLIST's display shows only data that is of
interest to WAIT; hence, it is more concise. PLIST shows
for each process: the process ID (PID), the parent's
process ID (PPID), the session number, and the name. All
numbers are hexadecimal.
2. This feature uses an undocumented OS/2 API call; it has
been tested with OS/2 SE 1.1 and 1.2, but may not work with
other or future versions.
3. WAIT only checks the status of the specified process
every five seconds or so; thus, up to about five seconds may
elapse between the termination of a process/session and
WAIT's noticing that this has occurred.
4. WAIT exits with an error if you specify a process by name
and more than one such process exists (PIDs are unique, but
names may not be).
(Thanks hereby expressed to those who investigated and
published the information about this useful API function!
Unlike WAIT, PLIST is uncopyrighted and is donated to the public
domain for use without restrictions.)
Cancelling the wait
-------------------
When WAIT goes to sleep, it displays the elapsed time before it
is going to wake up, then blocks its thread for the period
specified. (While it is sleeping, you can of course switch to
other sessions.) You can cancel the wait at any time by
pressing either Ctrl+C or Ctrl+Break.
If interrupted, WAIT wakes up and displays an option list; you
can select one of these three actions:
-- go back to sleep
-- terminate immediately
-- execute the command (if specified) immediately
Exit codes
----------
If WAIT is unsuccesful, it returns one of these exit codes
(errorlevels):
30000 - problem getting process information
30001 - problem setting up ^C/^Break signal handler
30002 - more than one instance of named process found
30003 - unable to execute specified command
30004 - cancelled by user (Ctrl+C, Ctrl+Break)
30005 - invalid date or time
30006 - improper syntax
If WAIT is successful, it returns the exit code of the child
process. With /D, this will be the exit code of the specific
program that was executed; without /D, it will be the exit code
returned by the command shell.
Version number
--------------
To display WAIT's version number and logo, use:
wait /V
Please be sure to know your version number before contacting
Cove Software about WAIT. All other arguments are ignored if /V
is specified.
Getting help
------------
To display a usage summary for WAIT, use either of:
wait /help
wait /?
All other arguments are ignored if these options are used.
Version history
---------------
1.10 02/06/91 (a quick update)
Added wait for process/session
Added TOMORROW keyword
Corrected /N option to /D (as documented)
Simplified quotation rules
Changed error exit codes to reduce chances of collision
with exit codes from commands
Eliminated diagnostics that slipped into the release
Added PLIST program
1.00 02/05/91
Initial release
Copyright/License/Warranty
--------------------------
This document and the program file WAIT.EXE ("the software") are
copyrighted by the author. If you are an individual, you are
licensed to: use the software; make as many copies of the
program and documentation as you wish; give such copies to
anyone; and distribute the software and documentation via
electronic means. There is no charge for any of the above.
However, you are specifically prohibited from charging, or
requesting donations, for any such copies, however made; and
from distributing the software and/or documentation with
commercial products without prior permission. An exception is
granted to not-for-profit user's groups, which are authorized to
charge a small fee (not to exceed $7) for materials, handling,
postage, and general overhead. NO FOR-PROFIT ORGANIZATION IS
AUTHORIZED TO CHARGE ANY AMOUNT FOR DISTRIBUTION OF COPIES OF
THE SOFTWARE OR DOCUMENTATION, OR TO INCLUDE COPIES OF THE
SOFTWARE OR DOCUMENTATION WITH SALES OF THEIR OWN PRODUCTS.
THIS INCLUDES A SPECIFIC PROHIBITION AGAINST FOR-PROFIT
ORGANIZATIONS DISTRIBUTING THE SOFTWARE, EITHER ALONE OR WITH
OTHER SOFTWARE, AND CHARGING A "HANDLING" OR "MATERIALS" FEE OR
ANY OTHER SUCH FEE FOR THE DISTRIBUTION. NO FOR-PROFIT
ORGANIZATION IS AUTHORIZED TO INCLUDE THE SOFTWARE ON ANY MEDIA
FOR WHICH MONEY IS CHARGED. PERIOD.
Businesses, institutions, and governmental entities are
prohibited from installing or using the software on their
systems without specific permission from The Cove Software
Group.
No copy of the software may be distributed or given away without
this document; and this notice must not be removed.
There is no warranty of any kind, and the copyright owner is not
liable for damages of any kind. By using this free software,
you agree to this.
The software and documentation are:
Copyright (C) 1991 by
The Cove Software Group
Christopher J. Dunford
P.O. Box 1072
Columbia, Maryland 21044
(301) 992-9371
CompuServe 76703,2002 [IBMNET]
Software and documentation author: Chris Dunford