本文共 384 字,大约阅读时间需要 1 分钟。
#!/usr/bin/expect -fset timeout 10# 切换到root用户, 然后执行ls和df命令:spawn su - rootexpect "Password*"send "123456\r"expect "]*" # 通配符send "ls\r"expect "#*" # 通配符的另一种形式send "df -Th\r"send "exit\r" # 退出spawn开启的进程expect eof # 退出此expect交互程序
#!/bin/baship="172.16.22.131"username="root"password="123456"# 指定执行引擎/usr/bin/expect <
转载地址:http://xijxz.baihongyu.com/