Net :: Telnet,尝试读取输出

时间:2013-03-21 15:10:49

标签: perl

我试图从我的设备读取这个输出,我如何使用打印和等待,我没有成功。

这是输出....

zSH> get v52-interface-group 1
v52-interface-group  1
name-id: --------------------->  {CTAA-024}
local-interface-id: ---------->  {1024}
local-prov-variant: ---------->  {2}
prov-variant-request: -------->  {norequest}
admin-status: ---------------->  {inservice}
pstn-layer-3-start-address: -->  {1}
isdn-env-func-start-address: ->  {1}
port-alignment-request: ------>  {norequest}
national-pstn-region: -------->  {brazil}
switch-vendor: --------------->  {nortel}
protocol-spec: --------------->  {edition2}
startup-check-link-id: ------->  {false}
startup-unblock-user-ports: -->  {false}
link-oos-timer: -------------->  {2500}
link-is-timer: --------------->  {200}

v52-link has 16 elements. Display [a]ll, [n]one, a [s]ubset, or [q]uit? q

这是我的代码的一部分,我试图阅读....

$string = "Display [a]ll, [n]one, a [s]ubset, or [q]uit?";
$tel->print("get v52-interface-group 1");
$tel->waitfor(String => $string);
@out = $tel->cmd('q');
print @out;

1 个答案:

答案 0 :(得分:0)

您应尝试使用正则表达式保护waitfor()中的方括号。

$string = "/Display\s+\[a\]ll,\s+\[n\]one,\s+a\s+\[s\]ubset,\s+or\s+\[q\]uit\?/";
$tel->waitfor($string);