home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / numpage < prev    next >
Text File  |  2020-01-01  |  5KB  |  130 lines

  1. #!/usr/local/bin/kermit +
  2. #
  3. # UNIX: Change "kerbang" line above to path of C-Kermit program.
  4. #
  5. # n u m p a g e  --  Send a numeric page or dial a beeper
  6. #
  7. # Arguments:
  8. # 1. Phone number
  9. # 2. Optional message (omit for beepers)
  10. #
  11. # Redials automatically in case of busy signal (if modem supports "@").
  12. # C-Kermit 7.0 or K95 1.1.19 required
  13. #
  14. # Notes:
  15. # . Accurate reporting of success or failure and the automatic redialing
  16. #   feature require a modem that supports the "Wait for Answer" dial
  17. #   modifier "@".
  18. # . Once the dial string is given to the modem, it is up to the modem to
  19. #   do its job and report accurately whether it succeeded.  Experiments
  20. #   with assorted modems give mixed results.  For example, "@" doesn't work
  21. #   with some modems unless the phone rings at least 2 or 3 times before
  22. #   picking up.
  23. #
  24. # Author: F. da Cruz, Columbia University, 16 April 1999.
  25. # Revised Feb 2000 for transparent portability between K95 and C-Kermit.
  26.  
  27. define badversion {
  28.     echo Sorry - C-Kermit 7.0 or K95 1.1.19 or later required.
  29.     if eq "\%0" "\v(cmdfil)" exit 1
  30.     stop 1
  31. }
  32. if not equal "\v(program)" "C-Kermit" badversion
  33. if LLT \v(version) 700196 badversion
  34.  
  35. local kerbang result debug device modem poundsign speed ; Local variables
  36.  
  37. .kerbang = 0                ; Assume no.
  38. if eq "\%0" "\v(cmdfil)" .kerbang = 1    ; This means we were.
  39.  
  40. define ERRQUIT {            ; Macro to exit appropriately
  41.     if def \%1 echo \%1            ; with an error message.
  42.     if \m(kerbang) exit 1        ; If Kerbang script, exit all the way.
  43.     stop 1                ; Otherwise return to Kermit prompt.
  44. }
  45. if not def \%1 errquit {Usage: \%0: phone-number [ numeric-message ]}
  46.  
  47. ; Get configuration parameters from environment variables. if any -- remove
  48. ; this section if you'd rather hard-wire the parameters into the script.
  49.  
  50. if not eq \v(system) WIN32 {        ; (Windows uses TAPI)
  51.     .modem := \$(MODEM)            ; Modem type
  52.     .device := \$(DEVICE)        ; Dialout device / port
  53. }
  54. .speed := \$(SPEED)            ; Port speed
  55. .redials := \$(REDIAL_LIMIT)        ; Number of times to redial if busy
  56. .pause := \$(REDIAL_PAUSE)        ; Pause between redials (sec)
  57.  
  58. ; Local parameters...
  59.  
  60. .debug = 0                ; (*) Change to 1 for debugging
  61. .poundsign = 1                ; (*) Change to 0 if "#" not required
  62. if not eq \v(system) WIN32 {
  63.   if not def modem .modem = usr        ; (*) Change to match your modem
  64.   if not def device .device = /dev/cua    ; (*) Change to your dialout device
  65. }
  66. if not def speed .speed = 2400        ; (*) Port speed - change if necessary
  67. if not def redials .redials = 20    ; (*) Change according to local laws!
  68. if not def pause .pause = 1        ; (*) Change according to local laws!
  69.  
  70. if \m(debug) {                ; Echo parameters...
  71.     echo { Number:      "\%1"}
  72.     echo { Message:     "\%2"} 
  73.     echo { Device:      "\m(device)"}
  74.     echo { Speed:       "\m(speed)"}
  75.     echo { Modem:       "\m(modem)"}
  76.     echo { Redials:     "\m(redials)"}
  77.     echo { Pause:       "\m(pause)"}
  78.     echo { Poundsign:   "\m(poundsign)"}
  79. }
  80.  
  81. if eq \v(system) WIN32 {        ; Set up dialing device
  82.     set tapi line            ; Use TAPI in Windows
  83.     if fail errquit {Error: Can't open TAPI device}
  84. } else {
  85.     set modem type \m(modem)        ; Specify modem type
  86.     if fail {                ; Check for error
  87.     errquit {Error: Modem type "\m(modem)" not known}
  88.     }
  89.     set line \m(device)            ; Open the device
  90.     if fail {                ; Check for failure
  91.     errquit {Error: \m(device) not available}
  92.     }
  93. }
  94.  
  95. def on_exit hangup            ; In case of Ctrl-C
  96. set exit warning off            ; In case of misconfigured modem
  97. set speed \m(speed)            ; Set the desired speed
  98.  
  99. ; Form the dial string...
  100.  
  101. if def \v(dm_wa) {            ; Have wait-For-Answer dial modifier
  102.     asg \%1 \%1\v(dm_wa)\%2        ; Insert it between number and message
  103.     set dial retries \m(redials)    ; Adjust to local laws and regulations
  104.     set dial interval \m(pause)        ; Ditto (see comments above)
  105. } else if def \%2 {            ; No Wait-For-Answer but message given
  106.     asg \%1 {\%1\frepeat(\v(dm_lp,5))\%2} ; Insert "long pause" before message
  107.     set dial retries 0            ; No automatic redialing
  108.     if \m(debug) {
  109.     echo { WARNING: This modem is not well-suited for paging.}
  110.     echo { Busy signals are not detected and failure is not reported.}
  111.     echo { Automatic redialing disabled.}
  112.     }
  113. }   
  114. ; Supply "#" at end of message if required and missing...
  115.  
  116. if ( def \%2 && \m(poundsign) && not eq "\fright(\%2,1)" "#" ) {
  117.     asg \%1 \%1#            ; if it was not there already
  118. }
  119. if \m(debug) {
  120.     echo { Dial string: "\%1"}        ; Show the final dial string
  121.     set dial display on            ; Watch computer/modem dialog
  122. }
  123. pdial \%1                ; Dial number but don't expect carrier
  124. .result := \v(status)            ; Remember PDIAL result
  125. if \m(debug) echo { Dial status: "\v(dialstatus)"}
  126. pause 2                    ; Give modem time to catch up
  127. hangup                    ; Hang up the phone
  128. if \m(kerbang) exit \m(result)
  129. end \m(result)                ; Exit with code from PDIAL result
  130.