博客
关于我
expect常见用法
阅读量:601 次
发布时间:2019-03-12

本文共 384 字,大约阅读时间需要 1 分钟。

  1. 直接通过expect执行多条命令
#!/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交互程序
  1. 通过shell调用expect执行多条命令
#!/bin/baship="172.16.22.131"username="root"password="123456"# 指定执行引擎/usr/bin/expect <

转载地址:http://xijxz.baihongyu.com/

你可能感兴趣的文章
mysql中null和空字符串的区别与问题!
查看>>