linux expect简介及安装

简介:       

        我们通过Shell可以实现简单的控制流功能,如:循环、判断等。但是对于需要交互的场合则必须通过人工来干预,有时候我们可能会需要实现和交互程序如telnet服务器等进行交互的功能。而Expect就是用来实现这种功能的工具。

  Expect是一个免费的编程工具语言,用来实现自动和交互式任务进行通信,而无需人的干预。Expect的作者Don Libes在1990年开始编写Expect时对Expect做有如下定义:Expect是一个用来实现自动交互功能的软件套件 (Expect is a software suite for automating interactive tools)。系统管理员使用它可以创建脚本对命令或程序提供输入,而这些命令和程序是期望从终端(terminal)得到输入,一般来说这些输入都是手工进行输入的。 Expect则可以根据程序的提示模拟标准输入提供给程序需要的输入来实现交互程序执行。

        简单来说就是脚本帮助你输入本该由你自己手动输入的信息。

安装:

-rw-r--r-- 1 ddd ddd  525572 2011-09-15 expect.tar.gz
-rw-r--r-- 1 ddd ddd 3641017 2011-09-15 tcl8.4.16-src.tar.gz
tar -xzvf解压

Expect需要Tcl编程语言的支持,要在系统上运行Expect必须首先安装Tcl

安装tcl:

[ddd@hh zx]$ cd /home/zx/tcl8.4.16/unix

通过该命令可以查看安装参数:

[ddd@hh unix]$./configure --help
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
  --cache-file=FILE       cache test results in FILE
  --help                  print this message
  --no-create             do not create output files
  --quiet, --silent       do not print `checking...' messages
  --version               print the version of autoconf that created configure
Directory and file names:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [same as prefix]
  --bindir=DIR            user executables in DIR [EPREFIX/bin]
  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
  --datadir=DIR           read-only architecture-independent data in DIR
                          [PREFIX/share]
  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
                          [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
  --includedir=DIR        C header files in DIR [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
  --infodir=DIR           info documentation in DIR [PREFIX/info]
  --mandir=DIR            man documentation in DIR [PREFIX/man]
  --srcdir=DIR            find the sources in DIR [configure dir or ..]
  --program-prefix=PREFIX prepend PREFIX to installed program names
  --program-suffix=SUFFIX append SUFFIX to installed program names
  --program-transform-name=PROGRAM
                          run sed PROGRAM on installed program names
Host type:
  --build=BUILD           configure for building on BUILD [BUILD=HOST]
  --host=HOST             configure for HOST [guessed]
  --target=TARGET         configure for TARGET [TARGET=HOST]
Features and packages:
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --x-includes=DIR        X include files are in DIR
  --x-libraries=DIR       X library files are in DIR
--enable and --with options recognized:
  --enable-man-symlinks   use symlinks for the manpages
  --enable-man-compression=PROG
                      compress the manpages with PROG
  --enable-man-suffix=STRING
                      use STRING as a suffix to manpage file names
                      (default: tcl)
  --enable-threads        build with threads
  --enable-shared         build and link with shared libraries [--enable-shared]
  --enable-64bit          enable 64bit support (where applicable)
  --enable-64bit-vis      enable 64bit Sparc VIS support
  --enable-corefoundation use CoreFoundation API [--enable-corefoundation]
  --disable-load          disallow dynamic loading and load command
  --enable-symbols        build with debugging symbols [--disable-symbols]
  --enable-langinfo       use nl_langinfo if possible to determine
                          encoding at startup, otherwise use old heuristic
  --enable-dtrace         build with DTrace support [--disable-dtrace]
  --enable-framework      package shared libraries in MacOSX frameworks [--disable-framework]:
设置安装参数:
[ddd@hh unix]$./configure --prefix=/home/zx/tcl
[ddd@hh unix]$make
[ddd@hh unix]$make install

拷贝头文件以供安装expect时使用:

[ddd@hh unix]$cp tclUnixPort.h ../generic/

安装expect:

[ddd@hh unix]$ cd /home/zx/expect-5.43

通过该命令可以查看安装参数:

[ddd@hh expect-5.43]$ ./configure --help
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
  --cache-file=FILE       cache test results in FILE
  --help                  print this message
  --no-create             do not create output files
  --quiet, --silent       do not print `checking...' messages
  --version               print the version of autoconf that created configure
Directory and file names:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [same as prefix]
  --bindir=DIR            user executables in DIR [EPREFIX/bin]
  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
  --datadir=DIR           read-only architecture-independent data in DIR
                          [PREFIX/share]
  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
                          [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
  --includedir=DIR        C header files in DIR [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
  --infodir=DIR           info documentation in DIR [PREFIX/info]
  --mandir=DIR            man documentation in DIR [PREFIX/man]
  --srcdir=DIR            find the sources in DIR [configure dir or ..]
  --program-prefix=PREFIX prepend PREFIX to installed program names
  --program-suffix=SUFFIX append SUFFIX to installed program names
  --program-transform-name=PROGRAM
                          run sed PROGRAM on installed program names
Host type:
  --build=BUILD           configure for building on BUILD [BUILD=HOST]
  --host=HOST             configure for HOST [guessed]
  --target=TARGET         configure for TARGET [TARGET=HOST]
Features and packages:
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --x-includes=DIR        X include files are in DIR
  --x-libraries=DIR       X library files are in DIR
--enable and --with options recognized:
  --enable-threads        build with threads (not supported)
  --with-tcl           directory containing tcl configuration (tclConfig.sh)
  --with-tk           directory containing tk configuration (tkConfig.sh)
  --enable-symbols   allow use of symbols if available
  --with-tclinclude       directory where tcl private headers are
  --enable-shared     build libexpect as a shared library
  --with-x               whether or not to use X (default yes)
  --with-tkinclude       directory where tk private headers are
  --disable-load     disallow dynamic loading
  --enable-gcc        allow use of gcc if available

设置安装参数:

[ddd@hh expect-5.43]$./configure --prefix=/home/zx/expect 
    -with-tcl=/home/zx/tcl/lib -with-x=no 
    -with-tclinclude=/home/zx/tcl8.4.16/generic
[ddd@hh expect-5.43]$make
[ddd@hh expect-5.43]$make install




 

 

 

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a19881029/article/details/8140874
个人分类: Linux / Shell
上一篇Oracle10g的spfile与pfile
下一篇JFreeChart时序图
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭