- 論壇徽章:
- 0
|
本帖最后由 jinwh12 于 2013-05-29 15:03 編輯
問(wèn):調(diào)用my @lines1 = $telnet->cmd('/sbin/ifconfig -a');為什么不能及時(shí)獲取到輸出呢? 如果不sleep 2秒的話,lines1的輸出 ,是在下一個(gè)print "linesps: @linesps\n"里面輸出的,有大拿知道是為什么嗎?
加sleep的輸出:
lines1:-bash-3.1$ /sbin/ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:10:18:63 : D2 :54
inet addr:192.168.32.222 Bcast:192.168.32.255 Mask:255.255.255.0
不加sleep的輸出:
lines1:/sbin/ifconfig -a
-bash-3.1
linesps:eth0 Link encap:Ethernet HWaddr 00:10:18:63 : D2 : 54
inet addr:192.168.32.222 Bcast:192.168.32.255 Mask:255.255.255.0
部分代碼如下:
------------------------------------------------------------------------------------------------------
#!env perl _w
#Author: autoCreated
use Net::Telnet;
#my $telnet=Net::Telnet->new("192.168.32.222" ) ;
#$telnet->login("oracle", "oracle" ) ;
my $telnet=new Net::Telnet('Host'=>'192.168.32.222','Timeout'=>30,'Dump_Log'=>'oracletelnet.log');
$telnet->waitfor('Match'=>"/[l|L]ogin:/" ) ;
$telnet->print("oracle" ) ;
$telnet->waitfor('Match'=>"/[p|P]assword:/" ) ;
$telnet->print("oracle" ) ;
$telnet->waitfor('/type?/');
$telnet->print("vt100" ) ;
$telnet->waitfor('Match'=>"/\>|\$|#/" ) ;
sleep 2;
my @lines1 = $telnet->cmd('/sbin/ifconfig -a');
print "@lines1\n";
sleep 2;
my @linesps = $telnet->cmd('ps -ef');
print "linesps: @linesps\n";
------------------------------------------------------------------------------------------------------------------- |
|