1、tcl命令安装
下载tcl安装包:https://sourceforge.net/projects/tcl/files/Tcl/8.6.12/tcl8.6.12-src.tar.gz/download
tar -zxf tcl8.6.12-src.tar.gz
cd tcl8.6.12/unix/
./configure --prefix=/usr/tcl --enable-shared
make
make install
# 目录tcl8.6.12/unix/下的tclUnixPort.h复制到generic中
cp tclUnixPort.h ../generic/
# 授权允许普通用户使用
chmod 755 /usr/tcl/lib/expect5.45.4
chmod -R 755 /usr/tcl
2、安装expect
# 下载expect地址:https://jaist.dl.sourceforge.net/project/expect/Expect/5.45.4/expect5.45.4.tar.gz
tar -zxf expect5.45.4.tar.gz
cd expect5.45.4
./configure --prefix=/usr/expect --with-tcl=/usr/tcl/lib --with-tclinclude=../tcl8.6.12/generic ##配置expect的安装路径,--with-tcl为告诉configure脚本tcl解释器位置,--with-tclinclude为告诉脚本tcl头文件位置
make
make install
ln -s /usr/tcl/bin/expect /usr/expect/bin/expect
chmod -R 755 /usr/expect
chmod 755 /usr/expect/bin
将命令写入环境变量
vi /etc/profile
export PATH=$PATH:/usr/expect/bin/
source /etc/profile
3、测试
输入expect命令,看是否进入形如expect1.1>这样的命令行