So I have this script and it works great at sending things over a socket after tailing a file. The problem seems to be when the recieving end is not available the program crashes. Is there a way to get the program to stay up and wait for the recieving end to be available?
[CODE=perl]
use File::Tail;
use IO::Socket;
{
local $/ = "\n";
my $name = 'filename';
$file=File::Tai l->new(name=> $name, maxinterval=>3, reset_tail=>0);
while (defined($line= $file->read)) {
# init host and port
my $host = 'ip';
my $port = 8264;
my $sock = new IO::Socket::INE T( PeerAddr => $host, PeerPort => $port, Proto => 'tcp');
$sock or die "no socket: $@";
chomp $ln;
print $sock $line;
print "$line";
close $sock;
}
}[/CODE]
Thanks for the help!
[CODE=perl]
use File::Tail;
use IO::Socket;
{
local $/ = "\n";
my $name = 'filename';
$file=File::Tai l->new(name=> $name, maxinterval=>3, reset_tail=>0);
while (defined($line= $file->read)) {
# init host and port
my $host = 'ip';
my $port = 8264;
my $sock = new IO::Socket::INE T( PeerAddr => $host, PeerPort => $port, Proto => 'tcp');
$sock or die "no socket: $@";
chomp $ln;
print $sock $line;
print "$line";
close $sock;
}
}[/CODE]
Thanks for the help!
Comment