This is what I changed it to. The time is not 0000 for testing. It still does not work.
#!/usr/bin/perl -w
use strict;
use IO::Socket;
use MIME::Lite;
use Time::Out qw(timeout);
$SIG{PIPE} = "IGNORE";
$| = 1;
my $nb_secs = 10;
my $buf = "";
my $file;
my $sock = new IO::Socket::INET (PeerAddr => '192.168.173.9',
PeerPort => 4002,
Proto => 'tcp',
Type => SOCK_STREAM,
);
die "cannot open socket" unless ($sock);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(t
+ime);
my $hrmin = sprintf ("%02d%02d",$hour,$min);
my $ymd = sprintf("%04d%02d%02d%02d%02d%02d",$year+1900,$mon+1,$mday,$
+hour,$min,$sec);
my $filename = "/tmp/$ymd.txt";
print $filename, "\n";
open $file, ">$filename" || die("Couldn't open $file");
while (my $line = <$sock>) {
# Close existing $file and reopen a new one at time listed.
if($hrmin eq 1228) {
sleep 1;
close $file;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localti
+me(time);
my $hrmin = sprintf ("%02d%02d",$hour,$min);
my $ymd = sprintf("%04d%02d%02d%02d%02d%02d",$year+1900,$mon+1,$md
+ay,$hour,$min,$sec);
my $filename = "/tmp/$ymd.txt";
print $filename, "\n";
open $file, ">$filename" || die("Couldn't open $file");
}
if ($line =~ m/^(ALARM: )/) {
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|