开发者

perl Net::Telnet module with telnet shell with no prompt character

开发者 https://www.devze.com 2023-01-13 21:27 出处:网络
The telnet host I am using does not have a prompt character, (it just goes into a blank newline when it is done), how then, should I use the Net::Telnetperl module?

The telnet host I am using does not have a prompt character, (it just goes into a blank newline when it is done), how then, should I use the Net::Telnet perl module?

I tried setting prompt to // '' /\s/ or /\s*开发者_StackOverflow中文版/ none of which worked.

'' gave error saying it was invalid, and // /\s/ and /\s*/ simply timed out.

my $t = new Net::Telnet (Timeout => 10, Prompt => '/\s*/');

edit: This connects fine, but when it tries to issue a command, it times out because it doesn't recognize the prompt.;


You can't use cmd or login if you can't get the remote side to issue a prompt, because they depend on the prompt to know when the command is finished.

You can use $telnet->print('command') to issue commands. How you read the output depends on how you expect to recognize the end of the output.

If there's some recognizable pattern on the last line, you can use waitfor in list context.

If you know how many lines of output there will be, you can use getline, and read that many lines.

In the worst case, I would probably use getline with a timeout, and assume that the command was finished after N seconds with no output.

0

精彩评论

暂无评论...
验证码 换一张
取 消