home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95 / npage.ksc < prev    next >
Text File  |  2020-01-01  |  4KB  |  90 lines

  1. # n u m p a g e  --  Send a numeric page or dial a beeper
  2. #
  3. # Arguments:
  4. # 1. Phone number
  5. # 2. Optional message (omit for beepers)
  6. #
  7. # Redials automatically in case of busy signal (if modem supports "@").
  8. # K95 1.1.19 required
  9. #
  10. # Notes:
  11. # . Accurate reporting of success or failure and the automatic redialing
  12. #   feature require a modem that supports the "Wait for Answer" dial
  13. #   modifier "@".
  14. # . Once the dial string is given to the modem, it is up to the modem to
  15. #   do its job and report accurately whether it succeeded.  Experiments
  16. #   with assorted modems give mixed results.  For example, "@" doesn't work
  17. #   with some modems unless the phone rings at least 2 or 3 times before
  18. #   picking up.
  19. #
  20. # Author: F. da Cruz, Columbia University, 16 April 1999.
  21.  
  22. local result debug device modem poundsign speed ; Local variables
  23.  
  24. if < \v(xversion) 1119 stop 1 K95 1.1.19 required 
  25.  
  26. if not def \%1 stop 1 Usage: \%0: phone-number [ numeric-message ]
  27.  
  28. ; Get configuration parameters from environment variables. if any -- remove
  29. ; this section if you'd rather hard-wire the parameters into the script.
  30.  
  31. .speed := \$(SPEED)                  ; Port speed
  32. .redials := \$(REDIAL_LIMIT)         ; Number of times to redial if busy
  33. .pause := \$(REDIAL_PAUSE)           ; How long to pause between redials (sec)
  34.  
  35. ; Local parameters...
  36.  
  37. .debug = 0                           ; (*) Change to 1 for debugging
  38. .poundsign = 1                       ; (*) Change to 0 if "#" not required
  39. if not def modem .modem = usr        ; (*) Change to match your modem
  40. if not def device .device = /dev/cua ; (*) Change to your dialout device
  41. if not def speed .speed = 2400       ; (*) Port speed - change if necessary
  42. if not def redials .redials = 20     ; (*) Change according to local laws!
  43. if not def pause .pause = 1          ; (*) Change according to local laws!
  44.  
  45. if \m(debug) {                       ; Echo parameters...
  46.     echo { Number:      "\%1"}
  47.     echo { Message:     "\%2"} 
  48.     echo { Device:      "\m(device)"}
  49.     echo { Speed:       "\m(speed)"}
  50.     echo { Modem:       "\m(modem)"}
  51.     echo { Redials:     "\m(redials)"}
  52.     echo { Pause:       "\m(pause)"}
  53.     echo { Poundsign:   "\m(poundsign)"}
  54. }
  55. set tapi line
  56. if fail stop 1 {Error: Can't open TAPI device}
  57. def on_exit hangup                   ; In case of Ctrl-C
  58. set exit warning off                 ; In case of misconfigured modem
  59. set speed \m(speed)                  ; Set the desired speed
  60.  
  61. ; Form the dial string...
  62.  
  63. if def \v(dm_wa) {                   ; Have wait-For-Answer dial modifier
  64.     asg \%1 \%1\v(dm_wa)\%2          ; Insert it between number and message
  65.     set dial retries \m(redials)     ; Adjust to local laws and regulations
  66.     set dial interval \m(pause)      ; Ditto (see comments above)
  67. } else if def \%2 {                  ; No Wait-For-Answer but message given
  68.     asg \%1 {\%1\frepeat(\v(dm_lp,5))\%2} ; Insert "long pause" before message
  69.     set dial retries 0               ; No automatic redialing
  70.     if \m(debug) {
  71.     echo { WARNING: This modem is not well-suited for paging.}
  72.     echo { Busy signals are not detected and failure is not reported.}
  73.     echo { Automatic redialing disabled.}
  74.     }
  75. }   
  76. ; Supply "#" at end of message if required and missing...
  77.  
  78. if ( def \%2 && \m(poundsign) && not eq "\fright(\%2,1)" "#" ) {
  79.     asg \%1 \%1#                     ; if it was not there already
  80. }
  81. if \m(debug) {
  82.     echo { Dial string: "\%1"}       ; Show the final dial string
  83.     set dial display on              ; Watch computer/modem dialog
  84. }
  85. pdial \%1                            ; Dial the number but don't expect carrier
  86. .result := \v(status)                ; Remember PDIAL result
  87. if \m(debug) echo { Dial status: "\v(dialstatus)"}
  88. pause 2                              ; Give modem time to catch up
  89. end \m(result)                       ; Set exit code from PDIAL result
  90.