home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume3 / dial.sample / example
Encoding:
Text File  |  1986-11-30  |  2.3 KB  |  70 lines

  1. # Example for a dial script.
  2. #
  3. # Connect to a remote UNIX machine through a PABX and obtain certain
  4. # information from a server account (`qomnews') on this machine.
  5. # The line through which the PABX can be accessed is defined in
  6. # /etc/remote under the name `pabx', thus...
  7.  
  8. line=pabx
  9.  
  10. # If the PABX receives ^A^B+, it responds with D+ indicating that
  11. # it is ready to accept a phone number.
  12. # Due to a bug in the PABX software, it sometimes responds with
  13. # two beeps; In this case, there is nothing we can do exept quit
  14. # and fix it by hand...
  15.  
  16. prolog \1\2+ 1
  17.     dial  D+
  18.     exit  \7\7  "Go buy a new PABX!\n"
  19.     exit  #     "No response from PABX.\n"
  20.  
  21. # Send the phone number of the remote UNIX machine.  Sleep 0.1 seconds
  22. # before actually transmitting the number (otherwise the PABX gets angry).
  23. # If we receive a V followed by a three-digit number and a plus sign,
  24. # the connection has been established successfully.  Several responses
  25. # of the form <letter>+ are used by the PABX to indicate that something
  26. # went wrong; these reponses are translated into useful messages.
  27.  
  28. dial 618\r 5,.1
  29.     exit  B+    "Port busy -- try later.\n"
  30.     exit  N+    "Out of order.\n"
  31.     exit  E+    "Invalid phone number.\n"
  32.     connected  V...+
  33.     exit  #      "Connection failed.\n"
  34.  
  35. # Transmit a carriage return in order to get the login prompt.
  36.  
  37. connected \r 5,.1
  38.     login "login: "
  39.     exit  #      "Login failed.\n"
  40.  
  41. # Login at the remote machine using the login name `qomnews'.
  42.  
  43. login qomnews\r
  44.     enter "name? "
  45.     exit  #      "QOM news server down.\n"
  46.  
  47. # The qomnews server prompts for a user name.  The name is obtained
  48. # from the file .qomid from the caller's home directory.
  49. # Note that a time-out of 15 seconds is scheduled in order to give
  50. # the server a resonable time for the response.
  51. # If all goes well, the server transmits a number of lines of the form
  52. #    You have <n> unseen letters
  53. #    You have <n> unseen entries in XYZ   
  54. # or simply
  55. #    You have seen all the news.
  56. # If the first `You' has been received, enter the `data' loop below.
  57.  
  58. enter "${~/.qomid}" 15
  59.     data \r\n\r\nYou You
  60.     exit O+     "Early disconnect."
  61.     exit #       "QOM news server is hung.\n"
  62.  
  63. # Print all data received from the remote machine on standard output
  64. # until either a time-out of 5 seconds occurs or the disconnect message
  65. # O+ is received.
  66.  
  67. data "" 5
  68.     exit O+
  69.     data * &
  70.