views:

101

answers:

1

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*/ 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.;

+3  A: 

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.

cjm