linux下用expect登陆远程机子执行指令
-
2024-05-17 05:10:50
- 来源:其他
-
在手机上看
扫一扫立即进入手机端
首先,要安装expect,linux expect的安装
1.安装相应的包
yum install -y tcl tclx tcl-devel
2.下载expect-5.43.tar.gz包(我这里用的这个包,大家也可以用别的)
根据参数,运行./configure
./configure --with-tcl=/usr/lib --with-tclinclude=/usr/include/tcl-private/generic
3.make && make install 安装完毕
简单的登陆别的机器执行命令,可行 (更详细的还得参考expect的有关说明)
expect.sh
#!/usr/local/bin/expect
set timeout 10
spawn ssh root@ip
expect “*password*“
send “123456\r“
expect “#“
send “service crond restart\r“
expect eof
注:expect的功能是很强大的,实现了无须人与系统交互的功能,已经成为SA的一个强大助手,要研究的彻底,还是需要大量的时间的。
相关资讯
更多-
运满满司机找货app手机版
中文|151.8M
-
美图秀秀64位版本
中文|179.4M
-
小米usb驱动程序
中文|
-
2345看图王电脑版
中文|25.2M
-
速8酒店
中文|49.6M
-
全免漫画软件
中文|37.5M