home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: OtherApp
/
OtherApp.zip
/
PMPAGER.ZIP
/
PMPAGER.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1991-11-02
|
13KB
|
308 lines
/* rexx */
/* ****************************************************************** */
/* */
/* PMPAGER.CMD (OS/2) */
/* */
/* Version 1.0 */
/* Copyright (c) 1991 Robert G Gaillard. */
/* */
/* ****************************************************************** */
/* */
/* PM-Pager is a REXX add-in program for the OS/2 communications */
/* program Pmcomm, by Multi-Net Communications, and uses several */
/* specialized function calls proprietary to that product. */
/* */
/* The purpose of PM-Pager is to monitor a telephone line that is */
/* connected to both a modem and an answering machine, recognize */
/* when a sufficient number of rings have been received to trigger */
/* the answering machine, and then dial a remote beeper or pager */
/* as notification that a call was received. Provision is made to */
/* send a (numeric) identifying message to pagers that provide a */
/* display feature. */
/* */
/* Refer to the full documentation provided with the program for */
/* additional details, warnings, licensing information and */
/* disclaimers. */
/* */
/* Input (REXX Arg List): */
/* Pmcomm Standard Parameters: */
/* Port */
/* Portname */
/* Screen_handle */
/* Dde_output */
/* Dde_input */
/* Semaphore */
/* */
/* Output: */
/* None */
/* */
/* External Calls: */
/* RxFuncAdd */
/* Pmcomm Functions: */
/* Init_dll */
/* Drop_dtr */
/* Get_ch */
/* Put_s */
/* Raise_dtr */
/* Read_timeout */
/* Sleep */
/* Wait_for */
/* */
/* ****************************************************************** */
/* */
/* */
/* ****************************************************************** */
/* */
/* Following are the variable parameters which may be modified to */
/* customize PM-Pager to individual needs. Please refer to the */
/* documentation for a more complete description of each field. */
/* */
/* ****************************************************************** */
/* */
init_string="AT"||, /* Standard command prefix */
"&F"||, /* Restore factory defaults */
"&C1"||, /* Monitor carrier */
"&D2"||, /* Monitor DTR */
"L0"||, /* Lower volume */
"M0"||, /* Run fully silent */
"Q0"||, /* Return response codes */
"S0=0"||, /* Do not answer */
"S11=50"||, /* Speed up tone dialing */
"X4" /* Use full response code set */
/* */
dial_command="ATD" /* Standard dial command string */
dial_type="T" /* T=Tone or P=Pulse */
dial_prefix="" /* Get outside line (e.g "9,") */
area_code="1800" /* Pager area code (if required) */
phone_number="5551234" /* Pager phone number */
pause_string=",,,,@" /* Pause and Wait for quiet answer */
message_dial_type="" /* T=Tone (if normal dial was P) */
pager_message="516*555*6789" /* Message to display on pager */
message_end="#" /* Terminator for pager message */
dial_suffix=",,,,;H" /* Pause and hang up */
reset_string="ATZ0" /* Standard Pmcomm modem setting */
ring_duration=10 /* Max seconds between rings */
times_to_notify=1 /* Number of times to call pager */
notify_wait=60 /* Delay before calling pager */
primary_trigger=4 /* Number of rings for answering */
/* machine to answer normally */
secondary_trigger=2 /* Number of rings for answering */
/* machine to answer in toll-saver */
max_response_time=15 /* Max time to allow for callback */
log_all="NO" /* Set to "YES" before reporting */
/* problems with PM-Pager */
/* */
/* ****************************************************************** */
/* */
/* End of user-customization parameters. */
/* */
/* ****************************************************************** */
signal on syntax name syntax_error
signal on halt name eoj_clean_up
parse arg port portname screen_handle dde_output dde_input semaphore
parse source . . fn .
if semaphore=""
then
do
say "Pmpager: Input parameters invalid"
say " Not invoked from Pmcomm"
exit(4)
end
call RxFuncAdd "init_dll","RxPmcomm","init_dll"
call init_dll
numeric digits 12
curr_dir=directory()
cr = "0d"x
crlf = "0d0a"x
log_file=curr_dir"\PMPAGER.LOG"
wait_time=(60*60*24*366*1000)
wait_time=600000
mrts=max_response_time*60
nw=notify_wait*1000
prev_ring=0
curr_ring=0
prev_series=999999999999
curr_series=999999999999
series_cnt=0
full_string=""||,
dial_command||,
dial_type||,
dial_prefix||,
area_code||,
phone_number||,
pause_string||,
message_dial_type||,
pager_message||,
message_end||,
dial_suffix
noring_msg=""
ring_msg=""
err_msg=""
call read_timeout "0",port
r_c=0
do until r_c=-1
call get_ch port
r_c=result
end
call drop_dtr port
call sleep 2000
call raise_dtr port
do forever
call put_s 'ATZ'||cr,port
call wait_for "OK",port
call sleep "2000"
call put_s init_string||cr,port
call wait_for "OK",port
if result=1
then
leave
end
call put_s "1b5b324a"x,screen_handle /* Clear Screen Routine */
call put_s "PM-Pager now active, waiting for ring..." crlf,
,screen_handle
dummy=stream(log_file,"c","open write")
dummy=lineout(log_file,"PM-Pager started at "time()" on",
date(w)", "date(l))
call read_timeout wait_time,port
do forever
call wait_for "RING",port
r_c=result
if r_c=1
then
do
curr_ring=(date(b)*86400)+time(s)
this_gap=curr_ring-prev_ring
prev_ring=curr_ring
if this_gap>ring_duration
then
do
series_cnt=1
curr_series=curr_ring
s_s=" "
lm=length(noring_msg)+2
end
else
do
series_cnt=series_cnt+1
s_s="s"
lm=length(ring_msg)+2
end
if lm=2 | log_all="YES"
then
lm=0
dummy=stream(log_file,"c","seek -"lm)
ring_msg=series_cnt" Ring"s_s" Detected at "time()" on",
date(w)", "date(l)
dummy=lineout(log_file,ring_msg)
noring_msg=""
if series_cnt>=primary_trigger,
| (series_cnt>=secondary_trigger,
& (curr_series-prev_series)>mrts)
then
do
call put_s ring_msg||crlf,screen_handle
prev_series=curr_series
call sleep nw
call read_timeout 50000,port
times_notified=0
times_tried=0
response_codes="RC="
do while times_notified<times_to_notify,
& times_tried<10
call put_s full_string||cr,port
call wait_for "OK","CONNECT","NO CARRIER",
"NO DIALTONE","BUSY","ERROR","NO ANSWER",port
r_c=result
response_codes=response_codes||r_c
if r_c>0 & r_c<4
then
do
times_notified=times_notified+1
call drop_dtr port
call sleep 3000
call raise_dtr port
end
else
do
times_tried=times_tried+1
call sleep 30000
end
end
if times_notified<times_to_notify
then
do
err_msg="ERROR attempting to dial pager at",
time()" on "date(w)", "date(l)
dummy=lineout(log_file,err_msg)
err_msg=" "response_codes
dummy=lineout(log_file,err_msg)
end
else
do
if times_notified=1
then
s_s=""
else
s_s="s"
if log_all\="YES"
then
response_codes=""
err_msg="Pager dialed" times_notified "time"s_s,
"at" time() "on" date(w)"," date(l),
response_codes
dummy=lineout(log_file,err_msg)
end
ring_msg=""
call read_timeout wait_time,port
end
else
if series_cnt>=secondary_trigger
then
prev_series=999999999999
end
else
do
lm=length(noring_msg)+2
if lm=2 | log_all="YES"
then
lm=0
dummy=stream(log_file,"c","seek -"lm)
noring_msg="No Ring, "date(l)" "time()"..."
dummy=lineout(log_file,noring_msg)
end
end
exit
/* */
eoj_clean_up:
lm=length(noring_msg)+2
if lm=2 | log_all="YES"
then
lm=0
dummy=stream(log_file,"c","seek -"lm)
noring_msg="No Ring, "date(l)" "time()"..."
dummy=lineout(log_file,noring_msg)
dummy=lineout(log_file,"PM-Pager ended at" time() "on",
date(w)", "date(l))
do forever
call put_s 'ATZ'||cr,port
call wait_for "OK",port
call sleep "2000"
call put_s reset_string||cr,port
call wait_for "OK",port
if result=1
then
leave
end
exit
/* */
syntax_error:
errormsg = "REXX error" rc "in line" sigl":" errortext(rc)
rc = lineout(log_file,date() time() fn "-" errormsg)
rc = lineout(log_file,date() time() fn "-" sourceline(sigl))
exit