Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   libexpect    ( 3 )

библиотека программных диалогов с интерактивными программами (programmed dialogue library with interactive programs)

Имя (Name)

libexpect - programmed dialogue library with interactive programs


Синопсис (Synopsis)

#include expect_tcl.h Expect_Init(interp);

cc files... -lexpect5.20 -ltcl7.5 -lm

Note: library versions may differ in the actual release.

The Expect_Init function adds expect commands to the named interpreter. It avoids overwriting commands that already exist, however aliases beginning with "exp_" are always created for expect commands. So for example, "send" can be used as "exp_send".

Generally, you should only call Expect commands via Tcl_Eval. Certain auxiliary functions may be called directly. They are summarized below. They may be useful in constructing your own main. Look at the file exp_main_exp.c in the Expect distribution as a prototype main. Another prototype is tclAppInit.c in the Tcl source distribution. A prototype for working with Tk is in exp_main_tk.c in the Expect distribution.

int exp_cmdlinecmds; int exp_interactive; FILE *exp_cmdfile; char *exp_cmdfilename; int exp_tcl_debugger_available;

void exp_parse_argv(Tcl_Interp *,int argc,char **argv); int exp_interpreter(Tcl_Interp *); void exp_interpret_cmdfile(Tcl_Interp *,FILE *); void exp_interpret_cmdfilename(Tcl_Interp *,char *); void exp_interpret_rcfiles(Tcl_Interp *,int my_rc,int sys_rc); char * exp_cook(char *s,int *len); void (*exp_app_exit)EXP_PROTO((Tcl_Interp *); void exp_exit(Tcl_Interp *,int status); void exp_exit_handlers(Tcl_Interp *); void exp_error(Tcl_Interp,char *,...);

exp_cmdlinecmds is 1 if Expect has been invoked with commands on the program command-line (using "-c" for example). exp_interactive is 1 if Expect has been invoked with the -i flag or if no commands or script is being invoked. exp_cmdfile is a stream from which Expect will read commands. exp_cmdfilename is the name of a file which Expect will open and read commands from. exp_tcl_debugger_available is 1 if the debugger has been armed.

exp_parse_argv reads the representation of the command line. Based on what is found, any of the other variables listed here are initialized appropriately. exp_interpreter interactively prompts the user for commands and evaluates them. exp_interpret_cmdfile reads the given stream and evaluates any commands found. exp_interpret_cmdfilename opens the named file and evaluates any commands found. exp_interpret_rcfiles reads and evalutes the .rc files. If my_rc is zero, then ~/.expectrc is skipped. If sys_rc is zero, then the system-wide expectrc file is skipped. exp_cook returns a static buffer containing the argument reproduced with newlines replaced by carriage-return linefeed sequences. The primary purpose of this is to allow messages to be produced without worrying about whether the terminal is in raw mode or cooked mode. If length is zero, it is computed via strlen. exp_error is a printf-like function that writes the result to interp->result.


Описание (Description)

This library contains functions that allow Expect to be used as a Tcl extension or to be used directly from C or C++ (without Tcl). Adding Expect as a Tcl extension is very short and simple, so that will be covered first.