Linux Shell自动交互(expect)
su root
yum install -y expect
---------------------------
vi test.sh
----------------------------------
#!/usr/bin/expect
spawn su root
expect "password: "
send "123456\r"
expect eof
exit
---------------------------
chmod 775 test.sh
-------------------------
在其它脚本里调用
#!/bin/sh
. ./binshscript.sh
#expect script
./test.sh
本文介绍如何使用expect工具实现Linux Shell的自动交互操作。通过安装expect并编写shell脚本,可以实现自动登录及执行特定命令等任务。该文详细展示了expect脚本的基本语法和使用流程。
1456

被折叠的 条评论
为什么被折叠?



