Hi,
Some data is being pushed out on another UNIX server to a specific port. I am trying to put a Perl script together that will capture this data and print it out. So far I have the following;
#!/usr/bin/perl -w
use strict;
use IO::Socket;
my $text = "";
my $port='the_port';
my $svr='the_host';
my $sock = new IO::Socket::INET (
PeerAddr => $svr,
PeerPort => $port,
Proto => 'tcp',
Type => SOCK_STREAM,
);
die "Could not connect to Port : $!\n" unless $sock;
binmode $sock;
$sock->autoflush(1);
print "Listening on $svr $port\n";
while (<$sock>) {
print;
}
close $sock;
The connect works as I get no error, but nothing is printed. I know data is there so have I misssed something ?
Try this instead. Add this line right after your "use IO::Socket" line
replace $new_sep with whatever input record separator you want to use:
IO::Socket->input_record_s