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