home *** CD-ROM | disk | FTP | other *** search
- /*
- ** This is a simple program to
- ** Answer the phone
- ** send a `status.text' file out over the modem
- **
- ** All the while, it logs _every_ input line, along with a date-stamp for
- ** when the line of text came in. As an IMHO desirable side-effect, the
- ** user can enter any arbitrary text after connecting, and it will be
- ** recorded, verbatim, in a log file.
- **
- ** Modem disconnects are neither observed nor generated by this program;
- ** what it does is monitor input for a RING string; if it finds one it
- ** emits an `ATA', then waits for UP TO 2 lines of input in order to
- ** locate a CONNECT; if that fails, it goes back to looking for RING
- ** lines. When there is a user nominally conencted to it, it is _still_
- ** looking for `RING' lines.
- **
- ** It ASSUMES that STDIO is associated with the modem. If run from a CLI
- ** or Shell, you should type RING and CONNECT strings for yourself.
- **
- ** I wrote this script for only one purpose:
- ** To answer the phone & announce the status of my BBS while I decided
- ** how to replace it. (I wound up going back to Proteus, at least for
- ** a while.)
- **
- ** To exit, you must use the ARexx hi (Halt Interpreter) command; ^C-^F
- ** breaks should be difficult or impossible to generate.
- **
- ** There are no other special caveats. If you use it with sercli & FIFO,
- ** then make sure you read the .log file once in a while & update the
- ** Status.text file as well. My way of updating Status.text was to
- ** compress most events down to a single line as soon as a newer event was
- ** added; each event had a date associated with it. Events were ordered
- ** from oldest to newest. Old events that had been compressed to one line
- ** were occaisionally deleted or merged with others. My last version of
- ** Status.text is included for giggles.
- **
- ** refuse_callers.rexx was run from a script very much like the sercli-run
- ** example for starting do_mail.rexx.
- **
- ** For pretty much the whole useful life span of this script, I ran it
- ** with an older version of sercli (v1.8).
- **
- */
- /*
- ** Custom handlers for these events; we don't want to let the user
- ** break out of our script!
- **
- */
- signal on break_c
- signal on break_d
- signal on break_e
- signal on break_f
-
- /*
- ** On `hi' (HALT), do a graceful exit.
- **
- */
- signal on halt
-
- log = 'log'
- log_file = 'refuse_callers.log'
- if ~open( log, log_file, 'a' ) then
- exit
-
- address command set_raw
- status = 'Status.text'
-
- call log( 'Starting' )
- top:
- do forever
- call wait_line( 'RING' )
- call writeln( stdout, 'ATA' || '0d'x )
- connect_line = wait_line( 'CONNECT', 2 )
- if 0 = pos( 'CONNECT', connect_line ) then
- call log( 'ERROR, no connect!' )
- else
- do
- call log( 'Connected with:' connect_line )
- /*
- ** call writeln( stdout, "(Login as `guest'.)" )
- ** address command 'rlaunch * "logout"'
- **
- */
- call send_file( status )
- call writeln( stdout, 'GMT time/date (yyyymmdd hhmmss):' time_date( ) )
- end
- end
- exit
-
- wait_line:
- parse arg wl_str, wl_max
- if datatype( wl_max, 'n' ) then
- wl_max = 'for 'wl_max
- else
- wl_max = ''
-
- wl_line = ''
- interpret 'do' wl_max 'until 0 ~= pos( wl_str, wl_line ); wl_line = getln( ); call log( wl_line ); end'
- return wl_line
-
- send_file:
- parse arg sf_fname
- sf_text = ''
- if ~open( 'sf_file', sf_fname, 'r' ) then
- do
- call log( 'Could not send file {'sf_fname'}' )
- call writeln( stdout, 'Could not send file {'sf_fname'}' || '0d'x )
- end
- else
- do
- do while ~eof( 'sf_file' )
- sf_line = readln( 'sf_file' )
- sf_text = sf_text || '0a'x || sf_line
- call writeln( stdout, sf_line'0d'x )
- end
- call close( 'sf_file' )
- end
- return sf_text
-
- getln:
- g_ln = ''
- g_done = 0
- do until g_done
- g_c = readch( stdin, 1 )
- g_done = ( ( ('0a'x == g_c) | ('0d'x == g_c) ) ) & (g_last ~= g_c)
- g_last = g_c
- if ~g_done then
- g_ln = g_ln || g_c
- end
- g_last = g_c
- return strip( g_ln, 'b', '0a0d'x )
-
- log:
- parse arg l_str
- return writeln( log, time_date( ) ':' l_str )
-
- time_date:
- parse value date( 's' ) time( ) with td_1 ':' td_2 ':' td_3
- return td_1 || td_2 || td_3
-
-
- break_c:
- break_d:
- break_e:
- break_f:
- signal on break_c
- signal on break_d
- signal on break_e
- signal on break_f
-
- call writeln( stdout, '0d'x )
- call writeln( stdout, 'Sending a break is a naughty thing to do.' || '0d'x )
- call writeln( stdout, '0d'x )
-
- signal top
-
- halt:
- call log( 'Ending' )
- address command set_con
- call writeln( stdout, '0d'x )
- call writeln( stdout, 'Breaking refuse_callers.rexx script...' || '0d'x )
- call writeln( stdout, '0d'x )
- exit 0
-