I am attempting to control a third party program using PERL via Net::Telnet in a Windows environment. I have successfully scripted logging onto the server and running some rudimentary commands. However, when I run a certain program, I'm getting unexpected results and I can't identify the problem using the debug tools/methods covered on the author's page on CPAN (e.g., examing the log file, using waitfor instead of cmd, etc., i.e., the problem is not a time out issue). I believe it might be related to raw data that is generated from the program (the visual screen output in this program shows the prompts in bold, and the input fields are highlighted). The first prompt in the program asks for an output file location. I successfully send the path, and an empty file gets created in that location. The next prompt asks for a description. The problem is this prompt never shows up in the output flow as seen in the log file generated by dump_log (so the use of cmd or waitfor to enter the next input doesn't work since the prompt never appears). It appears as if the connection is dropped at this point (see data output below). After the prompt for the file location is sent, there is some garbage characters and spaces returned that is the raw data. After that, I send the file name back. I know the program accepts the file name because a zero length file is created in the output location, but this is the last output received from the terminal in the logfile. Here's the log file output:

< 0x000a0: 30 6d 1b 5b 34 3b 31 48 1b 5b 4b 1b 5b 30 6d 46 0m.[4;1 +H.[K.[0mF < 0x000b0: 69 6c 65 3a 1b 5b 30 3b 37 6d 1b 5b 34 3b 37 48 ile:#fi +le prompt is here#.[0;7m.[4;7H < 0x000c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 + < 0x000d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 + < 0x000e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 + < 0x000f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 + < 0x00100: 20 20 20 20 20 20 20 20 1b 5b 34 3b 37 48 + .[4;7H > 0x00000: 66 69 6c 65 0d 0a file..# +file sent is here (just the name "file"#

After that, PERL sends the rest of the commands (there are some Y/N prompts that I respond to with print) and the script completes without error, but the file remains at zero length (it behaves as if the connection is lost as soon as I send the file path). If I enter the exact same information manually through telnet, it works fine. I was hoping someone here could give me some guidance on additional debugging techniques I could use to trouble shoot this issue, or if there are any ways to eliminate the raw data being sent from the terminal (I have tried cmd_remove_mode and turning off telnet_mode without any apparent difference). Thank you.


In reply to Net::Telnet - Controlling 3rd Party Program by MKJ747

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.