Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

@frozenwithjoy, thanks for the reply. To answer your questions:

  1. It doesn't seem that reversing the order of the commands
    print "$command\n";
    $exp->send("$command\n");
    
    makes any difference either to the STDOUT or logfile output. It still gives:
    (1) (2) Here is the second command
    error
    (3) Error on command #3
    (4) commit
    This is the last command
    Committing data
    (5) (6) exit
    Exiting program...
    
  2. The server script has to print out the "(1) " before it receives any input. When it gets a line, it simply prints out "(2) " , waits for the next line, prints "(3) ", waits for the next line, etc. The code isn't optimized, but that's at least the explanation of why the $counter = 1 and the first print statement comes before the loop.

    That is, if you ran the server script and entered stuff, you'd get:

    (1) This is the first line I typed.  Now I'm hitting <ENTER>
    (2) I'm typing more stuff.
    (3) exit
    Exiting program...
    
  3. Good question. The server script is actually representing what I cannot control in this. It may be a company-wide program I'm trying to interact with, or a Juniper router, or an IDS box, or probably a lot of other things. So unfortunately for this example I have to pretend that I can't modify the server's output. All I can do is interact with the (program, router, server, etc.) myself, see what it outputs when I interact with it manually, then try to reconstruct that exact output when my Expect.pm script interacts with the (program, router, server, etc.) in the same way.

In reply to Re^2: How can I show all input and output with Expect.pm by GeorgeAdams
in thread How can I show all input and output with Expect.pm by GeorgeAdams

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found