Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我也尝试简单地使用interact它,并且通过删除最后一个期望状态来使用它
interact
expect -re "$prompt" send -- "exit\r"
和
interact { -re "$prompt" { send -- "show vlan id 121\r" } }
我只是想将控制权传递给用户手动进行某些操作,当他退出时,其余的循环继续
要退出interact用户应该提供一些命令,以便它知道何时停止交互式会话。例如:
expect -re "$prompt" send -- "show vlan id 121\r" send_user "To exit interactive mode press Ctrl+C\n" interact \003 return send "show ip int br | ex una\r" expect "#" send "exit\n"; exit 0