callback 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. ###################################################################
  3. #
  4. # Script to dial the remote system, negotiate the connection, and send
  5. # it the id. Then wait for the modem to disconnect. Reset the modem
  6. # to answer mode and wait for the system to call back.
  7. #
  8. # The telephone number and modempass are used when establishing the
  9. # connection to the modem.
  10. #
  11. PHONE=555-1212
  12. MODEMPASS=modem_identifier
  13. #
  14. # Once the modem calls back, the account name and password are used for
  15. # a UNIX style login operation.
  16. #
  17. ACCOUNT=my_account_name
  18. PASSWORD=my_password
  19. ###################################################################
  20. #
  21. # Step 1. Dial the modem and negotiate the initial dialog.
  22. # note: the modem is configured to ignore loss of DCD at this point.
  23. # it is important that this be performed because the loss of DCD
  24. # will normally prevent system from working since 'modem' is used
  25. # for pppd.
  26. #
  27. # The script is terminated normally when the carrier is lost.
  28. #
  29. chat -v \
  30. TIMEOUT 3 \
  31. ABORT '\nBUSY\r' \
  32. ABORT '\nNO ANSWER\r' \
  33. ABORT '\nRINGING\r\n\r\nRINGING\r' \
  34. '' AT \
  35. 'OK-+++\c-OK' 'AT&C0&D2S0=0H0' \
  36. TIMEOUT 30 \
  37. OK ATDT$TELEPHONE \
  38. CONNECT '' \
  39. assword: $MODEMPASS \
  40. "\nNO CARRIER\r"
  41. if [ "$?" = "0" ]; then
  42. ###################################################################
  43. #
  44. # Step 2. Wait for the call back from the remote. This will wait for at most
  45. # 30 seconds for the call back should the first attempt fail or
  46. # something happen with the callback logic at the remote.
  47. #
  48. # note: when the callback occurs, the DCD setting is re-enabled.
  49. #
  50. # If some voice call should happen during this period, the system will
  51. # answer the telephone and then hang up on them. I realize that this is
  52. # rude, but there is little that this script can do.
  53. #
  54. chat -v \
  55. TIMEOUT 30 \
  56. ABORT '\nVOICE\r' \
  57. '\nRING\r' 'AT&C1A' \
  58. CONNECT '' \
  59. TIMEOUT 10 \
  60. ogin:--ogin: $ACCOUNT \
  61. TIMEOUT 45 \
  62. assword: $PASSWORD
  63. if [ "$?" = "0" ]; then
  64. exit 0
  65. fi
  66. fi
  67. ###################################################################
  68. #
  69. # The script has failed. Terminate the connection mode.
  70. #
  71. chat -v TIMEOUT 3 "" AT 'OK-+++\c-OK' 'AT&C1&D2S0=0H0' OK
  72. exit 1