expect 安装和简单实例

#!/usr/bin/expect
eval spawn scp output.zip [email protected]:/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 [email protected] \"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

 

你可能感兴趣的:(工具,shell)