redialer 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/sh
  2. ###################################################################
  3. #
  4. # These parameters control the attack dialing sequence.
  5. #
  6. # Maximum number of attempts to reach the telephone number(s)
  7. MAX_ATTEMPTS=10
  8. # Delay between each of the attempts. This is a parameter to sleep
  9. # so use "15s" for 15 seconds, "1m" for 1 minute, etc.
  10. SLEEP_DELAY=15s
  11. ###################################################################
  12. #
  13. # This is a list of telephone numbers. Add new numbers if you wish
  14. # and see the function 'callall' below for the dial process.
  15. PHONE1=555-1212
  16. PHONE2=411
  17. ###################################################################
  18. #
  19. # If you use the ppp-on script, then these are passed to this routine
  20. # automatically. There is no need to define them here. If not, then
  21. # you will need to set the values.
  22. #
  23. ACCOUNT=my_account_name
  24. PASSWORD=my_password
  25. ###################################################################
  26. #
  27. # Function to initialize the modem and ensure that it is in command
  28. # state. This may not be needed, but it doesn't hurt.
  29. #
  30. function initialize
  31. {
  32. chat -v TIMEOUT 3 '' AT 'OK-+++\c-OK'
  33. return
  34. }
  35. ###################################################################
  36. #
  37. # Script to dial a telephone
  38. #
  39. function callnumber
  40. {
  41. chat -v \
  42. ABORT '\nBUSY\r' \
  43. ABORT '\nNO ANSWER\r' \
  44. ABORT '\nRINGING\r\n\r\nRINGING\r' \
  45. '' ATDT$1 \
  46. CONNECT '' \
  47. ogin:--ogin: $ACCOUNT \
  48. assword: $PASSWORD
  49. #
  50. # If the connection was successful then end the whole script with a
  51. # success.
  52. #
  53. if [ "$?" = "0" ]; then
  54. exit 0
  55. fi
  56. return
  57. }
  58. ###################################################################
  59. #
  60. # Script to dial any telephone number
  61. #
  62. function callall
  63. {
  64. # echo "dialing attempt number: $1" >/dev/console
  65. callnumber $PHONE1
  66. # callnumber $PHONE2
  67. }
  68. ###################################################################
  69. #
  70. # Initialize the modem to ensure that it is in the command state
  71. #
  72. initialize
  73. if [ ! "$?" = "0" ]; then
  74. exit 1
  75. fi
  76. #
  77. # Dial telephone numbers until one answers
  78. #
  79. attempt=0
  80. while : ; do
  81. attempt=`expr $attempt + 1`
  82. callall $attempt
  83. if [ "$attempt" = "$MAX_ATTEMPTS" ]; then
  84. exit 1
  85. fi
  86. sleep "$SLEEP_DELAY"
  87. done