Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

OK. If you're on Linux, then the tn5250 app is reading from stdin. You should be able to drive it as a child process via IO::Pty (or open2/open3)and send it the same escape sequences that it expects to see.

e.g., to simulate pressing an up arrow to tn5250, you'll send a short character sequence to it's standard input.

You can work out which chars to send by hitting the docs or just running tn5250 under 'strace' and seeing it reads from fd 0 (the read(0, "...") bit when you hit the key.

You'll get the screen contents back from the stdout of the tn5250 process. These will contain escape sequences suitable for the terminal which tn5250 thinks you're running (probably vt100), which you could interpret and write the data at the appropriate offset in a screen buffer.

So, you'll end up emulating keystrokes to the tn5250 and understanding the escape sequences it sends back, so not a trivial task. It's perhaps also one which is prone to deadlock, if you're doing blocking reads from the app, so you'll probably want to use nonblocking reads if you can.

Maybe I've misunderstood, but I think that's what would be required. (Well, or re-implementing the 5250 network protocol your console app uses, or pulling apart the console app so you can call into it as a C API wrapped in XS, or adding (or finding) an existing scripting mechanism for this app, or...

Ah...CPAN goodness, there's Term::VT102 which might help a lot.


In reply to Re: Controlling a TTY via screen position by jbert
in thread Controlling a TTY via screen position by mutt

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (7)
    As of 2014-12-22 03:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (110 votes), past polls