Perl实现的Expect的telnet应用
来源:互联网 发布:联通多号通软件 编辑:程序博客网 时间:2024/06/06 11:59
一段简单的perl实现的telnet脚本,目的是打印当前的系统环境变量
深入Perl的expect,详见如下的链接
http://www.php-oa.com/2009/09/16/perl-expect.html
expect的perl实现详见如下的链接和说明
http://blog.chinaunix.net/u3/98375/showart_1968735.html
http://www.cnblogs.com/morebetter/archive/2007/04/18/718250.html
spawn($command,@params),Forks and execs $command. Returns an Expect object upon success or undef if the fork was unsuccessful or the command could not be found. spawn() passes its parameters unchanged to Perls exec(), so look there for detailed semantics。起了一个新进程用来执行$command命令
new expect()->expect($timeout,$content),Given $timeout in seconds Expect will wait for $object's handle to produce one of the match_patterns, which are matched exactly by default. If you want a regexp match, prefix the pattern with '-re'.在$timeout内,期待出现包含$content的内容,默认是精确匹配,也可以使用正则表达式,expect($timeout,re=>'')
new expect()->send($string):Sends the given strings to the spawned command. 发送消息
new expect()->debug(0|1|2): 打印debug 信息,不同的数字表示不同的bug级别
new expect()->interact(),和用户进行交互,把控制权转交给用户
new expect()->soft_close(), 软关闭,直到$timeout时间到达,才关掉该进程
new expect()->hard_close(),硬关闭,立刻关闭该进程
new expect()->match(),returns the string matched by the last expect() call, undef if no string was matched.返回匹配的结果
new expect()->match_number(),exp_match_number() returns the number of the pattern matched by the last expect() call. Keep in mind that the first pattern in a list of patterns is 1, not 0. Returns undef if no pattern was matched.返回匹配的个数
例子:
- Perl实现的Expect的telnet应用
- perl的expect使用方法,实现非交互式登录
- java版本的expect: 简单方式实现ssh/telnet与服务器端的交互和自动化测试
- perl的expect发送特殊字符问题
- redhat下安装perl的Expect
- 在iterm中用expect脚本实现ssh, telnet对aix, linux的自动登录
- 应用expect的自动应答
- 用perl打造自己的telnet服务端
- perl的expect和xml模块简单使用
- perl的expect和xml模块简单使用
- 使用perl的expect对linux下使用fdi…
- Perl脚本中Expect模块的学习使用
- linux expect, spawn 用expect实现自动登录的脚本
- shell编程expect的几个应用实例
- PERL Expect
- perl expect
- Perl数组的应用
- Perl数组的应用
- Study Java
- google code 的使用 svn下载别人的资源及其管理自己的代码(转)
- js从html获取提交给servlet,servlet把值返回html 出现中文乱码
- D-Bus学习(十一):在D-Bus上的telepathy[二]:进一步了解
- GoogleCode的SVN空间使用初步
- Perl实现的Expect的telnet应用
- ORA-00600: 内部错误代码, 参数: [32695], [hash aggregation can't be done]
- Flex分享: ResouceManager应用于本地化与国际化开发
- spring声明式事务配置方法(六):aop:config切入
- java extjs 链接数据库返回json
- 索引压缩问题
- 修改s3c440普通串口驱动为485驱动
- MYSQL中EXPLAIN的说明
- QQ的在线拼音输入法