离线安装expect

expect依赖tcl库

安装包:

           https://files.cnblogs.com/files/tozh/tcl8.4.11-src.tar.gz

           https://files.cnblogs.com/files/tozh/expect-5.43.0.tar.gz

我将两个压缩包传到了/opt/目录下

1,安装tcl

       tar xf tcl8.4.11-src.tar.gz

        cd tcl8.4.11/unix

        ./configure

        make && make install

2,安装expect

       tar xf expect-5.43.0.tar.gz

       cd expect-5.43.0

       ./configure --with-tclinclude=/opt/tcl8.4.11/generic --with-tclconfig=/usr/local/lib/

       make && make install

--------------------------------------------------------------------------------------------------------------------------------------------------------

#!/bin/bash
for i in `cat jisuan_ip`
do
/usr/bin/expect <<-EOF
set time 30
spawn sudo ssh $i
expect "yes/no" { send "yes\r" }
expect "password:"
send "PASSWORD\r"
expect "#" { send " cat /etc/zabbix/zabbix_agented.conf  \r" }
expect "#" { send "quit \r" }
EOF
done
#interact

猜你喜欢

转载自www.cnblogs.com/tozh/p/10096688.html