Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Perl-Sensitive Sunglasses
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I had much success using Net::Telnet to connect to a socket on a mainframe that delivered messages. Now that the mainframe had an upgrade and it seems to be sending EBCDIC rather than ascii. The mainframe people can't back out the change or figure out how to make the data be ascii again. I tried to adjust the Net::Telnet script to use a call to ebcdic2asciii found in Convert::EBCDIC. Of course nothing comes out or I wouldn't be writing. If I just telnet to the socket, I do see characters, weird ones of course. I assume I might be better off using IO:Socket::INET, but I am not sure how to make sure I stay connected unless the remote socket dies and how to tell I have 'enough' data that I can use ebcdic2ascii on. I simply want to print the incoming data to the screen. Here is telnet output, probably not useful, just showing there IS something.
Escape character is '^]'. cla;ccc}Q&P !cmcz«¦¢º€¡¦¢€ccmcz«¦¢º€¡¦¢€ccmcz«¦¢º€¡¦¢€ccmcz«¦¢º€¡¦¢€cc +mcz«¦¢º€¡¦¢€ccmcz«¦¢º€¡¦¢€ccmcz«¦¢º€¡¦¢€c^] telnet> quit
Here is my basic attempt, which connects but doesn't print anything.
#!/usr/bin/perl use IO::Socket::INET; use Convert::EBCDIC; my ($socket,$client_socket); $socket = new IO::Socket::INET ( PeerHost => '1.2.3.4', PeerPort => '6106', Proto => 'tcp', ) or die "ERROR in Socket Creation : $!\n"; print "TCP Connection Success.\n"; # read the socket data sent by server. $data = <$socket>; print "Received from Server : $data\n"; $data = ebcdic2ascii($data); print "Received from Server after : $data\n"; sleep (10); $socket->close();
Any ideas of what to try ? Thanks

In reply to Net::Telnet to IO::Socket::INET by sans-clue

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 browsing the Monastery: (8)
    As of 2014-04-20 09:07 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (485 votes), past polls