adlikon
asked on
Listen to A Port For Data & Print The Data
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 ?
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 ?
ASKER
Hi, now I get the following error;
"Can't locate auto/IO/Socket/INET/input_ recor.al in @INC (@INC contains: /sbcimp/run/pd/cpan/5.8.5- 2004.09/li b /usr/perl5/5.00503/sun4-so laris /usr/perl5/5.00503
/usr/perl5/site_perl/5.005 /sun4-sola ris /usr/perl5/site_perl/5.005 . /sbcimp/run/pd/cpan/5.8.6- 2005.03/li b /sbcimp/run/pd/cpan/5.8.6- 2005.03/bi n) at ./a.pl lin
e 30"
I have tried including libraries using;
BEGIN {
use lib qw( /sbcimp/run/pd/cpan/5.8.5- 2004.09/li b );
my @paths = (
"/sbcimp/run/pd/cpan/5.8.6 -2005.03/l ib",
"/sbcimp/run/pd/cpan/5.8.6 -2005.03/b in",
);
push @INC, @paths
}
I then get the error;
"Can't locate auto/IO/Socket/INET/input_ recor.al in @INC (@INC contains: /sbcimp/run/pd/cpan/5.8.5- 2004.09/li b /usr/perl5/5.00503/sun4-so laris /usr/perl5/5.00503
/usr/perl5/site_perl/5.005 /sun4-sola ris /usr/perl5/site_perl/5.005 . /sbcimp/run/pd/cpan/5.8.6- 2005.03/li b /sbcimp/run/pd/cpan/5.8.6- 2005.03/bi n) at ./a.pl lin
e 30"
I have done a search and can not find "input_recor.al" in any of our library directories which as far as I am aware are all standard. Is this new error a red herring ?
"Can't locate auto/IO/Socket/INET/input_
/usr/perl5/site_perl/5.005
e 30"
I have tried including libraries using;
BEGIN {
use lib qw( /sbcimp/run/pd/cpan/5.8.5-
my @paths = (
"/sbcimp/run/pd/cpan/5.8.6
"/sbcimp/run/pd/cpan/5.8.6
);
push @INC, @paths
}
I then get the error;
"Can't locate auto/IO/Socket/INET/input_
/usr/perl5/site_perl/5.005
e 30"
I have done a search and can not find "input_recor.al" in any of our library directories which as far as I am aware are all standard. Is this new error a red herring ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Now that I have rethought my requirment I need to approach this differently, so technically this is not the answer I need anymore but that is not the fault of Adam314. My orginal question is no longer vaild for my needs.
can you give me the complete perl code above, so that I know the complete answer at one place.
You can change the input record separator with:
$sock->input_record_separa