linux perl telnet安装,在perl中使用Telnet時遇到麻煩?

我遇到了一些麻煩發送命令,並從我設置的telnet連接接收文本/數據。在perl中使用Telnet時遇到麻煩?

#!perl

#Telnet.pl

use Net::Telnet;

# Create a new instance of Net::Telnet,

my $telnetCon = new Net::Telnet (Timeout => 20,

Dump_Log => "dump.log",

Input_Log => "infile.log",

Output_log => "output.log",

Prompt => '/\$ $/') or die "Could not make connection.";

# Connect to the host of the users choice

$telnetCon->open('');

#get username and password from user

my $CXusername = '';

my $CXpassword = '';

my $task = '50104'; # Get this input from the search

# Recreate the login

# Wait for the login: message and then enter the username

$telnetCon->waitfor(match => '/login:/i');

# this method adds a \n to the end of the username, it mimics hitting the enter key after entering your username

$telnetCon->print($CXusername);

$telnetCon->waitfor(match => '/Password:/i');

# does the same as the previous command but for the password

$telnetCon->print($CXpassword);

#Wait for the login successful message

$telnetCon->waitfor(match => '/$/');

$telnetCon->cmd("viewtask 50104");

$telnetCon->cmd(" ");

$telnetCon->cmd(" ");

@output = $telnetCon->cmd("who");

print @output;

($output) = $telnetCon->waitfor(match => '/$/');

print "Output: ",$output;

if($searched =~ /MODIFIED files in Task $_[1] :(.*?)The/s){

# to Logout of the telnet connection

$telnetCon->print("exit");

#return the modified data

return $1;

}

告訴我,如果問題沒有意義,我會嘗試並對其進行改寫。

257d5e64feb956fc01c4a39c04837379.png

f8d6a099efdf9a6cca08da513d38df9f.png

所以這是telnet視圖。當我輸入$ telnetCon-> cmd(「viewtask 50140」)時,我卡在第一張圖像上。我想到第二個圖像並繼續將命令輸入到我的telnet會話中。

2011-08-04

Shahab

+0

我不知道如果我得到你的問題,'$ telnetCon-> CMD( 「」);'超時?是'viewtask'等待輸入,任何機會? –

+0

嗯有點當我第一次進入viewtask ...它打印一些文件,然後等待另一個輸入來繼續顯示文件的其餘部分 –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值