免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1810 | 回复: 1
打印 上一主题 下一主题

expect 匹配问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-11-17 17:57 |只看该作者 |倒序浏览
我得到如下,如何匹配到 NOTICE TO USERS 在expect中

sss,Inc. System\r\nAuthorized Personnel Only\r\n***************************************************************************\r\n                            NOTICE TO USERS\r\n\r\n\r\nThis is a commercial computer system and is the property of sss, Inc.\r\nIt is for authorized use only. Users (authorized or unauthorized) have no\r\nexplicit or implicit expectation of privacy. Any or all uses of this system\r\nand all files on this system may be intercepted, monitored, recorded,\r\ncopied, audited, inspected, and disclosed to authorized site, sss,Inc.,\r\nand law enforcement personnel, as well as authorized officials of other\r\nagencies, both domestic and foreign. By using this system, the user consents\r\nto such interception, monitoring, recording, copying, auditing, inspection,\r\nand disclosure at the discretion of sss,Inc personnel.\r\nUnauthorized or improper use of this system may result in administrative\r\ndisciplinary action and civil and criminal penalties. By continuing to use\r\nthis system you indicate your awareness of and consent to these terms and\r\nconditions of use. LOG OFF IMMEDIATELY if you do not agree to the conditions\r\nstated in this warning.\r\n\r\n\r\n*****************************************************************************\r\n\r\n"

论坛徽章:
0
2 [报告]
发表于 2010-11-17 20:40 |只看该作者
本帖最后由 xiaopan3322 于 2010-11-17 20:43 编辑

回复 1# zhao3stones

用regexp(当然,也可以用string match)

  1. if {[regexp {NOTICE TO USERS} $parm]} {
  2.          puts "successful"
  3. }
复制代码
把parm赋值就行了
  1. #!/usr/bin/expect --
  2. set parm "sss,Inc. System\r\nAuthorized Personnel Only\r\n***************************************************************************\r\n   
  3.                         NOTICE TO USERS\r\n\r\n\r\nThis is a commercial computer system and is the property of sss, Inc.\r\nIt is for authori
  4. zed use only. Users (authorized or unauthorized) have no\r\nexplicit or implicit expectation of privacy. Any or all uses of this system\r\nan
  5. d all files on this system may be intercepted, monitored, recorded,\r\ncopied, audited, inspected, and disclosed to authorized site, sss,Inc.
  6. ,\r\nand law enforcement personnel, as well as authorized officials of other\r\nagencies, both domestic and foreign. By using this system, th
  7. e user consents\r\nto such interception, monitoring, recording, copying, auditing, inspection,\r\nand disclosure at the discretion of sss,Inc
  8. personnel.\r\nUnauthorized or improper use of this system may result in administrative\r\ndisciplinary action and civil and criminal penalti
  9. es. By continuing to use\r\nthis system you indicate your awareness of and consent to these terms and\r\nconditions of use. LOG OFF IMMEDIATE
  10. LY if you do not agree to the conditions\r\nstated in this warning.\r\n\r\n\r\n**************************************************************
  11. ***************\r\n\r\n"
  12. #use regexp
  13. if {[regexp {NOTICE TO USERS} $parm]} {
  14.         puts "successful"
  15. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP