expect 安装和简单实例

#!/usr/bin/expect
eval spawn scp output.zip liuyanjun@192.168.196.34:/tmp
set prompt ":|#|\\\$"
interact -o -nobuffer -re $prompt return
send "passworld\r"
interact -o -nobuffer -re $prompt return
expect eof"
      
set WildMiracleRoot /home/liuyanjun/workspace/new_project_framework/server/
eval spawn ssh -t liuyanjun@192.168.196.34 \"source .bash_profile && cd $WildMiracleRoot/frame/config/ConfigData/ && cp /tmp/output.zip ./ -f && unzip -o output.zip && cd $WildMiracleRoot/frame/ConfigSer/src/ && killall ConfigSer && sh clear.sh\"
      
interact -o -nobuffer -re $prompt return
send "passworld\r"
interact -o -nobuffer -re $prompt return
expect eof"

yum安装

       yum install  expect 

       yum install expect-devel

       yum install tcl 

 

参考:https://blog.csdn.net/supingemail/article/details/46680539

https://segmentfault.com/a/1190000003851594

 

上一篇:带你见证expect的强大——全程自动化执行命令


下一篇:Centos7安装可视化界面