Changeset 40178 in project


Ignore:
Timestamp:
06/07/21 13:16:58 (6 days ago)
Author:
svnwiki
Message:

Anonymous wiki edit for IP [78.85.48.72]: moved to https://wiki.call-cc.org/eggref/5/tcl-expect

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/expect

    r40152 r40178  
    1 == tcl-expect
    2 
    3 Chicken scheme binding to libexpect
    4 
    5 Expect is a tool for automating interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc. Expect really makes this stuff trivial. Expect is also useful for testing these same applications.
    6 
    7 === Author
    8 
    9 Aydar Zarifullin
    10 
    11 === Repository
    12 
    13 [[https://github.com/iZarif/ckn-expect|https://github.com/iZarif/ckn-expect]]
    14 
    15 === Dependencies
    16 
    17 * Linux
    18 * libtcl
    19 * libexpect
    20 
    21 '''Note''': Windows is not supported.
    22 
    23 === Installing
    24 
    25 ==== Debian-based system
    26 
    27 1. Install the dependencies
    28 
    29  apt install tcl-dev tcl-expect-dev
    30 
    31 2. Tell the compiler where the Tcl header files are located by setting the CSC_OPTIONS environment variable
    32 
    33  CSC_OPTIONS="-I/usr/include/tcl"
    34 
    35 3. Install this egg
    36 
    37  chicken-install tcl-expect
    38 
    39 ==== Arch-based system
    40 
    41 1. Install the dependencies
    42 
    43  pacman -S expect
    44 
    45 2. Determine the Expect version
    46 
    47  expect -version
    48 
    49 3. Create a symlink
    50 
    51  ln -s /usr/lib/expect<version>/libexpect<version>.so /usr/lib/libexpect.so
    52 
    53 Where <version> is the number from the previous step
    54 
    55 4. Install this egg
    56 
    57  chicken-install tcl-expect
    58 
    59 === Documentation
    60 
    61 <procedure>(call-with-process-io cmd proc)</procedure>
    62 
    63 Forks a new process and executes {{cmd}} then call {{proc}} which should be a procedure of three arguments: the input, output, and PID of the sub-process.
    64 
    65 '''Note''': The input and output ports will not be closed if {{proc}} raises an error
    66 
    67 While it is possible to use {{read-line}} to read information from a process spawned by {{call-with-process-io}}, more convenient function are provided.
    68 
    69 <procedure>(expect in-port pattern [timeout 10])</procedure>
    70 
    71 The function waits until the output from a process matches the pattern, a specified time period has passed, or an EOF is seen.
    72 The first argument to the function is an in-port the second argument is a Tcl glob-style string pattern the optional third argument sets timeout. The default timeout period is 10 seconds. A value of -1 disables a timeout from occurring. A value of 0 causes the function to return immediately.
    73 
    74 Returns one of the following values
    75 * ok
    76 * eof
    77 * timeout
    78 * fullbuffer
    79 
    80 === Example
    81 
    82 <enscript highlight="scheme">
    83 (import (prefix tcl-expect #:expect) (chicken io))
    84 
    85 (expect:call-with-process-io "bc"
    86                              (lambda (in out pid)
    87                               (expect:expect in "`warranty'")
    88                               (display "20+12\n" out)
    89                               (read-line in)
    90                               (read-line in)
    91                               (read-line in)
    92                               (display (read-line in))))
    93 </enscript>
    94 
    95 === Changelog
    96 
    97 * 0.1 Initial release
    98 * 0.2
    99 ** set-timeout function has been removed
    100 ** spawn function no longer uses 'sh' to execute commands
    101 ** expect function now takes an optional third argument - timeout
    102 
    103 === License
    104 
    105 Copyright 2021 Aydar Zarifullin.
    106 
    107 This program is free software: you can redistribute it and/or modify
    108 it under the terms of the GNU General Public License as published by
    109 the Free Software Foundation, either version 3 of the License, or
    110 (at your option) any later version.
    111 
    112 This program is distributed in the hope that it will be useful, but
    113 WITHOUT ANY WARRANTY; without even the implied warranty of
    114 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    115 General Public License for more details.
    116 
    117 A full copy of the GPL license can be found at
    118 <http://www.gnu.org/licenses/>.
Note: See TracChangeset for help on using the changeset viewer.