I am fairly new to programming and very new to perl. I am having an issue with what I believe should be a simple task. Here is the code I use to log onto a box, navagate to where I need to go (inside a menu drive (text) program) and run a report. While this is working, the output I am getting is including the menus and such before the report runs. I want just the report. Any tips or suggestions, please?
#!/usr/bin/perl my ($t, $op1, $op2); use Net::Telnet (); $t = new Net::Telnet; $t->open("192.168.1.1"); ## Open data file for writing open (nvfile, '>testout.txt'); ## Wait for first prompt and respond with 'era'. $t->waitfor('/login:/'); $t->print("era"); ## Wait for login prompt. $t->waitfor('/USER ID/'); $t->print("ANYUSER"); $t->print("ANYPASS"); ## Navigate to the report screen and select report to run. $t->waitfor('/SELECTION/'); $t->print("77"); $t->print("1"); $t->print("4"); $t->print("6910"); $t->print("?"); $t->print("10"); ## Run report On-screen and capture to file $t->print("O"); ($op1) = $t->waitfor('/Press any key to continue/'); print nvfile $op1; $t->print("N"); ($op2) = $t->waitfor('/REPORT COMPLETE/'); print nvfile $op2; $t->print(""); $t->print("END"); ## Logoff $t->waitfor('/SELECTION/'); $t->print("88"); $t->print("Y"); exit;
Thanks in advance for any tips or suggestions.

In reply to Net::Telnet / file question by sonicscott9041

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.