PERL-Expect:发送命令后获取输入。
我正在编写一个 PERL-Expect 脚本来自动化测试。在脚本中,我想在执行命令时获取警告消息,并根据警告消息采取行动。根据某些情况,警告消息可能会有所不同,并且警告可能根本不显示。
prompt>delete fs
WARNING: Are you sure?(Y/N).. backup is running:
在上面的场景中,我需要在继续之前获取警告消息作为输入,然后在发送回复之前进行一些处理。
在某些情况下,警告可能不会显示,如下所示,例如,如果没有运行备份并且执行命令而不对其进行处理:
prompt>delete fs
Done.
prompt>show fs
...
如果显示警告消息,如何在发送命令后获取警告消息?
谢谢。
I am writing a PERL-Expect script to automate testing. In the script I want to get the warning messages when a command is executed and take action based on the warning messages. The warning messages can differ based on some situations and also the warning may not be shown at all.
prompt>delete fs
WARNING: Are you sure?(Y/N).. backup is running:
In the above scenario I need to get the WARNING message as input before proceeding and then do some processing before sending a reply.
The warning may not be displayed as shown below in some cases, for e.g., if backup is not running and command be executed without processing them:
prompt>delete fs
Done.
prompt>show fs
...
How to get the warning message after the command is send if it is displayed?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 Expect 出发,您想要执行以下操作:
Going from Expect you'd want to do something like: