Lanthade has asked for the wisdom of the Perl Monks concerning the following question:

Greetings monks, I've got an annoying telnet problem I'm hoping you can shed some wisdom.

My telnet server (an Eiki projector) has decided that prompts are unnecessary. It's also decided that returns and/or newlines are also unnecessary after output. As you can guess this presents some problems with getting things done.

I've managed to get around the lack of a prompt by setting prompt to /.*/ which works, but I'm sure probably has some other dangerous issues.

My big problem is I need to record feedback from various commands and the lack of a \r or \n after the output has me stymied.

How would you handle this problem (given that I can't replace the projectors or get a proper prompt and \r\n behavior on the server).

Thanks!

  • Comment on Net::Telnet with an uncooperative server.

Replies are listed 'Best First'.
Re: Net::Telnet with an uncooperative server.
by regexes (Hermit) on Apr 12, 2013 at 06:42 UTC
    By default newline translation is done.
    I don't know if it will help... just an idea...

    Have you tried changing the binmode?
    $mode = 1 $obj->binmode($mode);
    From the Net::Telnet documentation:
    If $mode is 1 then binmode is on and newline translation is not done.

    If $mode is 0 then binmode is off and newline translation is done. In the input stream, each sequence of CR LF is converted to "\n" and in the output stream, each occurrence of "\n" is converted to a sequence of CR LF.
    Maybe you can then see in input_log() and dump_log() exactly what's happening.
Re: Net::Telnet with an uncooperative server.
by dasgar (Priest) on Apr 12, 2013 at 12:59 UTC

    After reading your post, I'm left with the impression that you're making guesses about the behavior of the device. I apologize if I'm making an incorrect assumption about that. Have you checked with documentation from the device's manufacturer? That would be my first step in debugging the situation.

    Which methods from Net::Telnet are you using to issue commands and reading back the output? Based on your comments about prompts, I'm assuming that you're using the cmd method, which submits a command and retrieves the output. As an alternative, you could try a combo of using the print method to issue the command and use get, getline or getlines to retrieve the output.

    Also, the log methods mentioned by regexes could prove to be useful in your debug efforts.