home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 July / CHIP797.ISO / xtension / linux / linux.exe / CHAT.MAN next >
Encoding:
Text File  |  1997-05-14  |  16.6 KB  |  463 lines

  1.  
  2.  
  3.  
  4. CHAT(8)                                                   CHAT(8)
  5.  
  6.  
  7. NNAAMMEE
  8.        chat - Automated conversational script with a modem
  9.  
  10. SSYYNNOOPPSSIISS
  11.        cchhaatt [ _o_p_t_i_o_n_s ] _s_c_r_i_p_t
  12.  
  13. DDEESSCCRRIIPPTTIIOONN
  14.        The _c_h_a_t program defines a conversational exchange between
  15.        the computer and the modem.  Its  primary  purpose  is  to
  16.        establish the connection between the Point-to-Point Proto¡
  17.        col Daemon (_p_p_p_d) and the remote's _p_p_p_d process.
  18.  
  19. OOPPTTIIOONNSS
  20.        --ff _<_c_h_a_t _f_i_l_e_>
  21.               Read the chat script from the chat _f_i_l_e. The use of
  22.               this  option  is  mutually  exclusive with the chat
  23.               script parameters. The user must have  read  access
  24.               to  the  file.  Multiple lines are permitted in the
  25.               file. Space or horizontal tab characters should  be
  26.               used to separate the strings.
  27.  
  28.        --tt _<_t_i_m_e_o_u_t_>
  29.               Set  the  timeout  for  the  expected  string to be
  30.               received. If the string is not received within  the
  31.               time  limit  then  the reply string is not sent. An
  32.               alternate reply may be sent or the script will fail
  33.               if  there  is  no  alternate reply string. A failed
  34.               script will cause the  _c_h_a_t  program  to  terminate
  35.               with a non-zero error code.
  36.  
  37.        --rr _<_r_e_p_o_r_t _f_i_l_e_>
  38.               Set  the  file for output of the report strings. If
  39.               you use the keyword _R_E_P_O_R_T, the  resulting  strings
  40.               are  written  to  this  file. If this option is not
  41.               used and you still use _R_E_P_O_R_T keywords, the  _s_t_d_e_r_r
  42.               file is used for the report strings.
  43.  
  44.        --vv     Request  that the _c_h_a_t script be executed in a ver¡
  45.               bose mode. The _c_h_a_t program will then log all  text
  46.               received  from  the  modem  and  the output strings
  47.               which it sends to the SYSLOG.
  48.  
  49.        --VV     Request that the  _c_h_a_t  script  be  executed  in  a
  50.               stderr verbose mode. The _c_h_a_t program will then log
  51.               all text received from the  modem  and  the  output
  52.               strings  which  it sends to the stderr device. This
  53.               device is usually the local console at the  station
  54.               running  the chat or pppd program. This option will
  55.               not work properly if the stderr  is  redirected  to
  56.               the  /dev/null  locaiton as is the case should pppd
  57.               be run in the 'detached' mode. In  that  case,  use
  58.               the '-v' option to record the session on the SYSLOG
  59.               device.
  60.  
  61.  
  62.  
  63.  
  64. Chat Version 1.9            5 May 1995                          1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. CHAT(8)                                                   CHAT(8)
  71.  
  72.  
  73.        ssccrriipptt If the script is not specified in a file  with  the
  74.               _-_f option then the script is included as parameters
  75.               to the _c_h_a_t program.
  76.  
  77. CCHHAATT SSCCRRIIPPTT
  78.        The _c_h_a_t script defines the communications.
  79.  
  80.        A script consists of one or more  "expect-send"  pairs  of
  81.        strings, separated by spaces, with an optional "subexpect-
  82.        subsend" string pair, separated by a dash as in  the  fol¡
  83.        lowing example:
  84.  
  85.               ogin:-BREAK-ogin: ppp ssword: hello2u2
  86.  
  87.        This  line  indicates  that the _c_h_a_t program should expect
  88.        the string "ogin:". If it fails to receive a login  prompt
  89.        within  the  time interval allotted, it is to send a break
  90.        sequence to the remote and then expect the string "ogin:".
  91.        If  the  first "ogin:" is received then the break sequence
  92.        is not generated.
  93.  
  94.        Once it received the login prompt the  _c_h_a_t  program  will
  95.        send  the string ppp and then expect the prompt "ssword:".
  96.        When it receives the prompt for the password, it will send
  97.        the password hello2u2.
  98.  
  99.        A  carriage  return  is  normally sent following the reply
  100.        string. It is not expected in the "expect"  string  unless
  101.        it  is  specifically  requested  by using the \r character
  102.        sequence.
  103.  
  104.        The expect sequence should contain only what is needed  to
  105.        identify the string. Since it is normally stored on a disk
  106.        file, it should not contain variable  information.  It  is
  107.        generally not acceptable to look for time strings, network
  108.        identification strings, or other variable pieces  of  data
  109.        as an expect string.
  110.  
  111.        To help correct for characters which may be corrupted dur¡
  112.        ing the initial sequence,  look  for  the  string  "ogin:"
  113.        rather  than "login:". It is possible that the leading "l"
  114.        character may be received in error and you may never  find
  115.        the string even though it was sent by the system. For this
  116.        reason, scripts look for "ogin:" rather than "login:"  and
  117.        "ssword:" rather than "password:".
  118.  
  119.        A very simple script might look like this:
  120.  
  121.               ogin: ppp ssword: hello2u2
  122.  
  123.        In   other  words,  expect  ....ogin:,  send  ppp,  expect
  124.        ...ssword:, send hello2u2.
  125.  
  126.        In actual practice, simple scripts are rare. At  the  vary
  127.  
  128.  
  129.  
  130. Chat Version 1.9            5 May 1995                          2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. CHAT(8)                                                   CHAT(8)
  137.  
  138.  
  139.        least,  you should include sub-expect sequences should the
  140.        original string not be received. For example, consider the
  141.        following script:
  142.  
  143.               ogin:--ogin: ppp ssowrd: hello2u2
  144.  
  145.        This  would  be  a  better script than the simple one used
  146.        earlier. This would look for the same login: prompt,  how¡
  147.        ever, if one was not received, a single return sequence is
  148.        sent and then it will look for login: again.  Should  line
  149.        noise  obscure  the  first  login  prompt then sending the
  150.        empty line will usually generate a login prompt again.
  151.  
  152. AABBOORRTT SSTTRRIINNGGSS
  153.        Many modems will report  the  status  of  the  call  as  a
  154.        string.  These  strings  may be CCOONNNNEECCTTEEDD or NNOO CCAARRRRIIEERR or
  155.        BBUUSSYY. It is often desirable to terminate the script should
  156.        the modem fail to connect to the remote. The difficulty is
  157.        that a script would not know exactly which modem string it
  158.        may receive. On one attempt, it may receive BBUUSSYY while the
  159.        next time it may receive NNOO CCAARRRRIIEERR.
  160.  
  161.        These "abort" strings may be specified in the script using
  162.        the  _A_B_O_R_T sequence. It is written in the script as in the
  163.        following example:
  164.  
  165.               ABORT BUSY ABORT 'NO CARRIER' '' ATZ OK ATDT5551212
  166.               CONNECT
  167.  
  168.        This  sequence  will  expect  nothing;  and  then send the
  169.        string ATZ. The expected response to this  is  the  string
  170.        _O_K.  When  it  receives _O_K, the string ATDT5551212 to dial
  171.        the telephone. The expected  string  is  _C_O_N_N_E_C_T.  If  the
  172.        string  _C_O_N_N_E_C_T is received the remainder of the script is
  173.        executed. However, should the modem find a busy telephone,
  174.        it  will  send the string _B_U_S_Y. This will cause the string
  175.        to match the abort character  sequence.  The  script  will
  176.        then fail because it found a match to the abort string. If
  177.        it received the string _N_O _C_A_R_R_I_E_R, it will abort  for  the
  178.        same  reason. Either string may be received. Either string
  179.        will terminate the _c_h_a_t script.
  180.  
  181.  
  182. RREEPPOORRTT SSTTRRIINNGGSS
  183.        A rreeppoorrtt string is similar to the ABORT string.  The  dif¡
  184.        ference  is  that  the  strings, and all characters to the
  185.        next control character such  as  a  carriage  return,  are
  186.        written to the report file.
  187.  
  188.        The report strings may be used to isolate the transmission
  189.        rate of the modem's connect string and return the value to
  190.        the  chat  user.  The  analysis of the report string logic
  191.        occurs in conjunction with  the  other  string  processing
  192.        such as looking for the expect string. The use of the same
  193.  
  194.  
  195.  
  196. Chat Version 1.9            5 May 1995                          3
  197.  
  198.  
  199.  
  200.  
  201.  
  202. CHAT(8)                                                   CHAT(8)
  203.  
  204.  
  205.        string for a report and abort  sequence  is  probably  not
  206.        very useful, however, it is possible.
  207.  
  208.        The report strings to no change the completion code of the
  209.        program.
  210.  
  211.        These "report" strings may  be  specified  in  the  script
  212.        using  the _R_E_P_O_R_T sequence. It is written in the script as
  213.        in the following example:
  214.  
  215.               REPORT CONNECT ABORT BUSY '' ATDT5551212 CONNECT ''
  216.               ogin: account
  217.  
  218.        This  sequence  will  expect  nothing;  and  then send the
  219.        string ATDT5551212 to dial  the  telephone.  The  expected
  220.        string  is  _C_O_N_N_E_C_T. If the string _C_O_N_N_E_C_T is received the
  221.        remainder of the script is executed. In addition the  pro¡
  222.        gram  will  write  to the expect-file the string "CONNECT"
  223.        plus any characters which follow it such as the connection
  224.        rate.
  225.  
  226. TTIIMMEEOOUUTT
  227.        The  initial  timeout  value  is  45  seconds. This may be
  228.        changed using the --tt parameter.
  229.  
  230.        To change the timeout value for the  next  expect  string,
  231.        the following example may be used:
  232.  
  233.               ATZ  OK ATDT5551212 CONNECT TIMEOUT 10 ogin:--ogin:
  234.               TIMEOUT 5 assowrd: hello2u2
  235.  
  236.        This will change the timeout to 10 seconds when it expects
  237.        the  login:  prompt. The timeout is then changed to 5 sec¡
  238.        onds when it looks for the password prompt.
  239.  
  240.        The timeout, once changed, remains in effect until  it  is
  241.        changed again.
  242.  
  243. SSEENNDDIINNGG EEOOTT
  244.        The  special  reply  string of _E_O_T indicates that the chat
  245.        program should send an EOT character to the  remote.  This
  246.        is  normally  the End-of-file character sequence. A return
  247.        character is not sent following the EOT.  The EOT sequence
  248.        may  be  embedded  into the send string using the sequence
  249.        _^_D.
  250.  
  251. GGEENNEERRAATTIINNGG BBRREEAAKK
  252.        The special reply string of _B_R_E_A_K will cause a break  con¡
  253.        dition  to  be  sent. The break is a special signal on the
  254.        transmitter. The normal processing on the receiver  is  to
  255.        change  the  transmission  rate.   It may be used to cycle
  256.        through the available transmission  rates  on  the  remote
  257.        until  you  are able to receive a valid login prompt.  The
  258.        break sequence may be embedded into the send string  using
  259.  
  260.  
  261.  
  262. Chat Version 1.9            5 May 1995                          4
  263.  
  264.  
  265.  
  266.  
  267.  
  268. CHAT(8)                                                   CHAT(8)
  269.  
  270.  
  271.        the _\_K sequence.
  272.  
  273. EESSCCAAPPEE SSEEQQUUEENNCCEESS
  274.        The expect and reply strings may contain escape sequences.
  275.        All of the sequences are legal in the reply  string.  Many
  276.        are legal in the expect.  Those which are not valid in the
  277.        expect sequence are so indicated.
  278.  
  279.        ''''     Expects or sends a null string. If you send a  null
  280.               string  then  it will still send the return charac¡
  281.               ter. This sequence may either be a pair of apostro¡
  282.               phe or quote characters.
  283.  
  284.        \\bb     represents a backspace character.
  285.  
  286.        \\cc     Suppresses  the  newline  at  the  end of the reply
  287.               string. This is the only method to  send  a  string
  288.               without  a trailing return character. It must be at
  289.               the end  of  the  send  string.  For  example,  the
  290.               sequence hello\c will simply send the characters h,
  291.               e, l, l, o.  _(_n_o_t _v_a_l_i_d _i_n _e_x_p_e_c_t_._)
  292.  
  293.        \\dd     Delay for one second.  The  program  uses  sleep(1)
  294.               which  will delay to a maximum of one second.  _(_n_o_t
  295.               _v_a_l_i_d _i_n _e_x_p_e_c_t_._)
  296.  
  297.        \\KK     Insert a BREAK _(_n_o_t _v_a_l_i_d _i_n _e_x_p_e_c_t_._)
  298.  
  299.        \\nn     Send a newline or linefeed character.
  300.  
  301.        \\NN     Send a null character. The  same  sequence  may  be
  302.               represented by \0.  _(_n_o_t _v_a_l_i_d _i_n _e_x_p_e_c_t_._)
  303.  
  304.        \\pp     Pause  for  a  fraction  of  a second. The delay is
  305.               1/10th of a second.  _(_n_o_t _v_a_l_i_d _i_n _e_x_p_e_c_t_._)
  306.  
  307.        \\qq     Suppress writing the string to the SYSLOG file. The
  308.               string  ??????  is written to the log in its place.
  309.               _(_n_o_t _v_a_l_i_d _i_n _e_x_p_e_c_t_._)
  310.  
  311.        \\rr     Send or expect a carriage return.
  312.  
  313.        \\ss     Represents a space character in  the  string.  This
  314.               may  be  used when it is not desirable to quote the
  315.               strings which contains  spaces.  The  sequence  'HI
  316.               TIM' and HI\sTIM are the same.
  317.  
  318.        \\tt     Send or expect a tab character.
  319.  
  320.        \\\\     Send or expect a backslash character.
  321.  
  322.        \\dddddd   Collapse the octal digits (ddd) into a single ASCII
  323.               character and send that character.   _(_s_o_m_e  _c_h_a_r_a_c_¡
  324.               _t_e_r_s _a_r_e _n_o_t _v_a_l_i_d _i_n _e_x_p_e_c_t_._)
  325.  
  326.  
  327.  
  328. Chat Version 1.9            5 May 1995                          5
  329.  
  330.  
  331.  
  332.  
  333.  
  334. CHAT(8)                                                   CHAT(8)
  335.  
  336.  
  337.        ^^CC     Substitute  the sequence with the control character
  338.               represented by C.  For example, the  character  DC1
  339.               (17)  is  shown  as  ^Q.   _(_s_o_m_e _c_h_a_r_a_c_t_e_r_s _a_r_e _n_o_t
  340.               _v_a_l_i_d _i_n _e_x_p_e_c_t_._)
  341.  
  342. TTEERRMMIINNAATTIIOONN CCOODDEESS
  343.        The _c_h_a_t program will terminate with the following comple¡
  344.        tion codes.
  345.  
  346.        00      The  normal  termination of the program. This indi¡
  347.               cates that the script was executed without error to
  348.               the normal conclusion.
  349.  
  350.        11      One  or  more  of  the parameters are invalid or an
  351.               expect  string  was  too  large  for  the  internal
  352.               buffers.  This  indicates  that  the program as not
  353.               properly executed.
  354.  
  355.        22      An error occurred during the execution of the  pro¡
  356.               gram.  This may be due to a read or write operation
  357.               failing for some reason or chat receiving a  signal
  358.               such as SIGINT.
  359.  
  360.        33      A  timeout  event occurred when there was an _e_x_p_e_c_t
  361.               string without having a "-subsend" string. This may
  362.               mean  that you did not program the script correctly
  363.               for the condition or that some unexpected event has
  364.               occurred  and  the  expected  string  could  not be
  365.               found.
  366.  
  367.        44      The first  string  marked  as  an  _A_B_O_R_T  condition
  368.               occurred.
  369.  
  370.        55      The  second  string  marked  as  an _A_B_O_R_T condition
  371.               occurred.
  372.  
  373.        66      The third  string  marked  as  an  _A_B_O_R_T  condition
  374.               occurred.
  375.  
  376.        77      The  fourth  string  marked  as  an _A_B_O_R_T condition
  377.               occurred.
  378.  
  379.        ......    The other termination codes are also strings marked
  380.               as an _A_B_O_R_T condition.
  381.  
  382.        Using  the  termination  code, it is possible to determine
  383.        which event terminated  the  script.  It  is  possible  to
  384.        decide if the string "BUSY" was received from the modem as
  385.        opposed to "NO DIAL TONE". While the first  event  may  be
  386.        retried,  the  second  will probably have little chance of
  387.        succeeding during a retry.
  388.  
  389. SSEEEE AALLSSOO
  390.        Additional information about _c_h_a_t  scripts  may  be  found
  391.  
  392.  
  393.  
  394. Chat Version 1.9            5 May 1995                          6
  395.  
  396.  
  397.  
  398.  
  399.  
  400. CHAT(8)                                                   CHAT(8)
  401.  
  402.  
  403.        with  UUCP  documentation.  The _c_h_a_t script was taken from
  404.        the ideas proposed by the scripts used by the _u_u_c_i_c_o  pro¡
  405.        gram.
  406.  
  407.        uucico(1), uucp(1)
  408.  
  409. CCOOPPYYRRIIGGHHTT
  410.        The  _c_h_a_t program is in public domain. This is not the GNU
  411.        public license. If it breaks then you  get  to  keep  both
  412.        pieces.
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460. Chat Version 1.9            5 May 1995                          7
  461.  
  462.  
  463.