亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪(fǎng)問(wèn)板塊 發(fā)新帖
查看: 4162 | 回復(fù): 9
打印 上一主題 下一主題

perl telnet 模塊的問(wèn)題 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2010-12-31 12:03 |只看該作者 |倒序?yàn)g覽
#!/opt/dc_perl

use Net::Telnet;

print "\nUsage: get_alarm.pl remote_host_ip port User_Name Password \n\n";

my $remote_host_ip = $ARGV[0];
my $port = $ARGV[1] ;
my $username = $ARGV[2] ;
my $password = $ARGV[3] ;
my $recv_file_name = $ARGV[4] ;

my $first_cmd ="cd /tellin/oams/oams_run/log";
my $second_cmd = "ps -ef|grep -v grep|grep tail|awk '{print $2}'|xargs kill -9";
my $third_cmd = "tail -f /tellin/oams/oams_run/log/oams_warninglog_usr.log";


print "ipremote_host_ip\n";
print "portport\n";
print "loginusername\n";
print "passwdpassword\n";

my $telnet_hd=new Net::Telnet (Timeout => 3600);
print "now telnet......\n";
#$telnet_hd->open(Host=>$remote_host_ip);
$telnet_hd->open(Host=>$remote_host_ip,Port=>$port);
print "now open ......\n";
$telnet_hd->login(login=>$username,Password=>$password);
print "now login......\n";

執(zhí)行perl程序的時(shí)候提示如下,哪位幫忙看看是啥問(wèn)題?
Usage: get_alarm.pl remote_host_ip port User_Name Password
ip:192.168.1.149
port:23
nameams
passwdams
now telnet......
now open ......

手工telnet服務(wù)器的時(shí)候
telnet 192.168.1.149
Trying 192.168.1.149...
Connected to 192,168.1.149.
Escape character is '^]'.
Welcome to SUSE Linux Enterprise Server 10 SP1 (x86_64) - Kernel 2.6.16.46-0.12-smp (2).

linux-461u login:

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2010-12-31 14:15 |只看該作者
你的prompt 在哪?

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2010-12-31 15:33 |只看該作者
#!c:/Perl

use Net::Telnet;

print "\nUsage: get_alarm.pl remote_host_ip port User_Name Password \n\n";

my $remote_host_ip = $ARGV[0];
my $port = $ARGV[1] ;
my $username = $ARGV[2] ;
my $password = $ARGV[3] ;
my $recv_file_name = $ARGV[4] ;

my $first_cmd ="cd /var/log/report";
my $second_cmd = "ps -ef|grep -v grep|grep tail|awk '{print $2}'|xargs kill -9";
my $third_cmd = "tail -f Alarm.log";


print "ipremote_host_ip\n";
print "portport\n";
print "nameusername\n";
print "passwdpassword\n";

my $telnet_hd=new Net::Telnet (Timeout => 10);
print "now telnet......\n";
#$telnet_hd->open("$remote_host_ip";
print "ceshi....\n";
$telnet_hd->open(Host=>$remote_host_ip,Port=>$port);
print "now open ......\n";
$telnet_hd->login(Name=>$username,PASSWORD=>$password);
print "now login......\n";

    if(!$telnet_hd)
    {
       print "Login Failed\n";
       $telnet_hd->close;
       exit 0;
     }

print "first cmd is $first_cmd\n";
$telnet_hd->print("$first_cmd";
print "send first cmd\n";
my ($cmd_result_msg,$match)= $telnet_hd->waitfor(Match=>"/report/",Timeout=>600000);

`sleep 3` ;
print "second cmd is $second_cmd\n";
$telnet_hd->print("$second_cmd";
print "send second cmd\n";
my ($cmd_result_msg,$match)= $telnet_hd->waitfor(Match=>"/report/",Timeout=>600000);

`sleep 3` ;
$telnet_hd->print("$third_cmd";
print "the third cmdthird_cmd\n";

while(my $line = $telnet_hd->getline())

{
        syswrite(stdout,$line);
}

print "begin quit\n";
$telnet_hd->close;

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2010-12-31 15:36 |只看該作者
perl -d get_alarm.pl 92.168.1.149 23  oams  oams

Loading DB routines from perl5db.pl version 1.28
Editor support available.

Enter h or `h h' for help, or `perldoc perldebug' for more help.

main:get_alarm.pl:5): print "\nUsage: get_alarm.pl remote_host_ip port User_Na
me Password \n\n";

  DB<1> n

Usage: get_alarm.pl remote_host_ip port User_Name Password

main:get_alarm.pl:7): my $remote_host_ip = $ARGV[0];

  DB<1> n
main:get_alarm.pl:: my $port = $ARGV[1] ;

  DB<1> n
main:get_alarm.pl:9): my $username = $ARGV[2] ;

  DB<1> n
main:get_alarm.pl:10):        my $password = $ARGV[3] ;

  DB<1> n
main:get_alarm.pl:11):        my $recv_file_name = $ARGV[4] ;

  DB<1> n
main:get_alarm.pl:13):        my $first_cmd ="cd /var/log/report";

  DB<1> n
main:get_alarm.pl:14):        my $second_cmd = "ps -ef|grep -v grep|grep tail|
awk '{print $2}'|xargs kill -9";

  DB<1> n
main:get_alarm.pl:15):        my $third_cmd = "tail -f Alarm.log";

  DB<1> n
main:get_alarm.pl:1:        print "ipremote_host_ip\n";

  DB<1> n
ip:192。168.1.149
main::(get_alarm.pl:19):        print "portport\n";

  DB<1> n
port:23
main::(get_alarm.pl:20):        print "nameusername\n";

  DB<1> n
nameams
main::(get_alarm.pl:21):        print "passwdpassword\n";

  DB<1> n
passwdams
main::(get_alarm.pl:23):        my $telnet_hd=new Net::Telnet (Timeout => 10);

  DB<1> n
main::(get_alarm.pl:24):        print "now telnet......\n";

  DB<1> n
now telnet......
main::(get_alarm.pl:26):        print "ceshi....\n";

  DB<1> n
ceshi....
main::(get_alarm.pl:27):        $telnet_hd->open(Host=>$remote_host_ip,Port=>$po
rt);

  DB<1> n
main::(get_alarm.pl:2:        print "now open ......\n";

  DB<1> n
now open ......
main::(get_alarm.pl:29):        $telnet_hd->login(Name=>$username,PASSWORD=>$pas
sword);

  DB<1> n
timed-out waiting for command prompt at get_alarm.pl line 29
at C:/Perl/site/lib/Net/Telnet.pm line 2036
        Net::Telnet::_croak('Net::Telnet=GLOB(0x1f57dc4)', 'timed-out waiting fo
r command prompt') called at C:/Perl/site/lib/Net/Telnet.pm line 539
        Net::Telnet::error('Net::Telnet=GLOB(0x1f57dc4)', 'timed-out waiting for
command prompt') called at C:/Perl/site/lib/Net/Telnet.pm line 1088
        Net::Telnet::__ANON__[C:/Perl/site/lib/Net/Telnet.pm:1097]('timed-out wa
iting for command prompt') called at C:/Perl/site/lib/Net/Telnet.pm line 1146
        Net::Telnet::login('Net::Telnet=GLOB(0x1f57dc4)', 'Name', 'oams', 'PAS
SWORD', 'oams') called at get_alarm.pl line 29
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.

  DB<1>   這是單步的執(zhí)行結(jié)果  誰(shuí)知道咋回事

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2010-12-31 15:40 |只看該作者
提示很清楚了-- timed-out waiting for command prompt'
看你的代碼中,似乎并沒(méi)有設(shè)置prompt的匹配,當(dāng)然就會(huì)產(chǎn)生這樣的超時(shí)了。建議你看看Net::Telnet中的示例代碼。
貼代碼最好禁用笑臉?lè)?hào), 夾雜在中間,代碼沒(méi)法看啊。

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2010-12-31 15:49 |只看該作者
prompt 匹配怎么設(shè)置啊  我對(duì)perl不熟

論壇徽章:
0
7 [報(bào)告]
發(fā)表于 2010-12-31 15:53 |只看該作者

  1. use Net::Telnet ();
  2.     $t = new Net::Telnet (Timeout => 10,
  3.                           Prompt => '/bash\$ $/');

復(fù)制代碼
Prompt 需要根據(jù)你遠(yuǎn)程機(jī)器上的命令提示符做相應(yīng)的修改哦!

論壇徽章:
0
8 [報(bào)告]
發(fā)表于 2010-12-31 16:00 |只看該作者
能不能幫忙發(fā)一份相關(guān)的例子?

論壇徽章:
0
9 [報(bào)告]
發(fā)表于 2010-12-31 16:02 |只看該作者
需要例子,最好莫過(guò)于模塊本身提供的了,
到這里看看去吧
http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm

論壇徽章:
0
10 [報(bào)告]
發(fā)表于 2010-12-31 16:49 |只看該作者
print "ipremote_host_ip\n";
print "portport\n";
print "nameusername\n";
print "passwdpassword\n";

my $telnet_hd=new Net::Telnet (Timeout => 10,
                                             Prompt => '/login:/');
print "now telnet......\n";
#$telnet_hd->open("$remote_host_ip";
$telnet_hd->open(Host=>$remote_host_ip,Port=>$port) or die "Can't open the connection:  $!";
print "now open ......\n";
$telnet_hd->login($username,$password);
print "now login......\n";     

現(xiàn)在提示main:get_alarm.pl:29):        $telnet_hd->login($username,$password);

  DB<2> n
login failed: bad name or password at get_alarm.pl line 29
at C:/Perl/site/lib/Net/Telnet.pm line 2036
        Net::Telnet::_croak('Net::Telnet=GLOB(0x1f57f84)', 'login failed: bad na
me or password') called at C:/Perl/site/lib/Net/Telnet.pm line 539
        Net::Telnet::error('Net::Telnet=GLOB(0x1f57f84)', 'login failed: bad nam
e or password') called at C:/Perl/site/lib/Net/Telnet.pm line 1150
        Net::Telnet::login('Net::Telnet=GLOB(0x1f57f84)', 'nrmdal', 'nrmdal') ca
lled at get_alarm.pl line 29
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.

  DB<2> n
Use `q' to quit or `R' to restart.  `h q' for details.

  DB<2>   誰(shuí)幫忙看一下啊
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專(zhuān)區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP