必备软件
下载软件的地址建议使用浏览器直接下载,下载的文件为*.tar文件,使用下载软件下载的*.tar.gz可能会出现问题。
下载后的*.tar文件建议解压放在/usr/local目录下。
1. 配置tcl
- 解压&&编译
tar -xvf tcl8.6.10.tar
cd tcl8.6.10
cd unix
sudo ./configure --prefix=/usr/local/tcl
sudo make
sudo make install
sudo cp ./tclUnixPort.h ../generic/
2.配置expect
- 解压&&配置
sudo tar -xvf expect5.45.4.tar
cd expect5.45.4
sudo ./configure --prefix=/usr/local/expect --with-tcl=/usr/local/tcl/lib --with-tclinclude=/usr/local/tcl8.6.10/generic
sudo make
sudo make install
3.配置远程免密登录脚本
创建login.sh脚本:
vim login.sh
脚本内容如下:
#! /usr/bin/expect
set timeout 30
set userName admin
set host 116.62.0.212
set passwd 123456
spawn ssh $userName@$host
expect {
"(yes/no)?" {
send "yes\n"
expect "password:"
send "$passwd\n"
}
"password:" {
send "$passwd\n"
}
}
interact
添加脚本可执行权限
sudo chmod +x login.sh
执行脚本:
./login.sh
参考:
https://blog.csdn.net/qq_26440803/article/details/89500129
https://blog.csdn.net/JW_xueZhiXia/article/details/54144116?locationNum=3&fps=1
来源:CSDN
作者:金马2
链接:https://blog.csdn.net/hbj206/article/details/103834955