• Linux expect源码安装


    首先下载expect5.45.3.tar.gz和tcl8.4.20-src.tar.gz安装包  

    链接: https://download.csdn.net/download/cdpc_xiao_wei/12720586

    expect依赖tcl,首先安装tcl

    一、TCL安装

    • 解压 
      tar -zxvf tcl8.4.20-src.tar.gz
    • 安装
    cd tcl8.4.20/unix
    ./configure --prefix=/usr/local/tcl --enable-shared
    make
    make install
    • tclUnixPort.h 复制到generic
      cp /usr/local/tcl8.4.20/unix/tclUnixPort.h /usr/local/tcl8.4.20/generic/

    二、安装expect

    • 解压
    tar xfvz expect5.45.3.tar.gz
    • 安装
    cd expect5.45.3
    ./configure --prefix=/usr/local/expect --with-tcl=/usr/local/tcl/lib --with-tclinclude=/usr/local/tcl8.4.20/generic
    make
    make install
    • 创建软连接
    ln -s /usr/local/tcl/bin/expect /usr/local/expect/bin/expect
    ln -s /usr/local/expect/bin/expect /bin/expect

    三、便于多个服务器安装,整理安装脚本

    本次脚本安装的源码在/usr/local/software/目录下,可以自己改动

    安装tcl

    #!/bin/bash
    [ -f /etc/init.d/functions ] && . /etc/init.d/functions
    install_tcl_path=/usr/local/
    tcl_name=tcl8.4.20-src.tar.gz
    tcl_dir=tcl8.4.20
    if [ -f /usr/local/software/$tcl_name ]; then
        echo "-------cp tcl8.4.20-src.tar.gz ----------"
        cp ${install_tcl_path}software/${tcl_name} ${install_tcl_path}${tcl_name}
        else
            echo "-------${tcl_name} not exist------------"
        exit 2
    fi
    cd ${install_tcl_path}
    echo "-------enter $(pwd)-------"
    echo "-------unzip ${tcl_name}-------"
    tar xfvz ${tcl_name}
    echo "-------unzip ${tcl_name} completed-------"
    sleep 2
    echo "------- install tcl-------"
    cd ${tcl_dir}/unix
    sleep 3
    [ -d $install_tcl_path ]||mkdir $install_tcl_path
     ./configure --prefix=${install_tcl_path}tcl --enable-shared
     if [ $? -ne 0 ];then
        echo "configure failed ,please check it out!"
        exit 3
        else
            echo "make tcl, please wait for few minutes"
            make
    fi
    if [ $? -ne 0 ];then
        echo "make failed ,please check it out!"
        exit 4
        else
            echo "install tcl, please wait for few minutes"
            make install
      if [ $? -ne 0 ];then
        echo "make install error,please check it out"
        exit 5
      else
        echo "make install succeed!!!"
        cp ${install_tcl_path}${tcl_dir}/unix/tclUnixPort.h ${install_tcl_path}${tcl_dir}/generic/
      fi
    fi

    安装expect

    #!/bin/bash
    [ -f /etc/init.d/functions ] && . /etc/init.d/functions
    install_path=/usr/local/
    file_name=expect5.45.3.tar.gz
    file_dir=expect5.45.3
    tcl_dir=/usr/local/tcl8.4.20
    if [ -f /usr/local/software/$file_name ]; then
        echo "-------cp expect5.45.3.tar.gz ----------"
        cp ${install_path}software/${file_name} ${install_path}${file_name}
        else
            echo "-------${file_name} not exist------------"
        exit 2
    fi
    cd ${install_path}
    echo "-------enter $(pwd)-------"
    echo "-------unzip ${file_name}-------"
    tar xfvz ${file_name}
    echo "-------unzip ${file_name} completed-------"
    sleep 2
    echo "------- install tcl-------"
    cd ${file_dir}
    sleep 3
    [ -d $install_path ]||mkdir $install_path
     ./configure --prefix=${install_path}expect --with-tcl=${install_path}tcl/lib --with-tclinclude=${tcl_dir}/generic
     if [ $? -ne 0 ];then
        echo "configure failed ,please check it out!"
        exit 3
        else
            echo "make tcl, please wait for few minutes"
            make
    fi
    if [ $? -ne 0 ];then
        echo "make failed ,please check it out!"
        exit 4
        else
            echo "install expect5, please wait for few minutes"
            make install
      if [ $? -ne 0 ];then
        echo "make install error,please check it out"
        exit 5
      else
        echo "make install succeed!!!"
        echo "------- Establish a synchronized link ------ "
        ln -s ${install_path}tcl/bin/expect ${install_path}expect/bin/expect
        ln -s ${install_path}expect/bin/expect /bin/expect
      fi
    fi

    expect的简单使用参考 Linux 通过Expect自动实现远程拷贝Scp自动输入密码

  • 相关阅读:
    【数据结构】KMP算法
    【数据结构】银行问题
    ejs模板渲染页面
    node的知识点
    http搭建服务器
    http接收页面传递的数据
    http模块
    node的http模块
    node的fs模块
    base.css
  • 原文地址:https://www.cnblogs.com/xiaoweiv/p/13554401.html
Copyright © 2020-2023  润新知