
IlovePERL!
Novice
Oct 18, 2012, 4:32 PM
Post #9 of 14
(1368 views)
|
|
Re: [IlovePERL!] Seeking a few pointers in basic FIFO script
[In reply to]
|
Can't Post
|
|
Hello, does this like the correct syntax using fh's? #!/usr/bin/perl -w use strict; use warnings; use File::Basename qw(basename); use Sys::Syslog qw(:DEFAULT setlogsock); my $fifo_file= "/var/log/xferlog.fifo"; my $syslog_facility = 'daemon'; my $syslog_level ='info'; my $program= "proftpd"; my $hlhome= "/home/liveupload/http-live"; my $lhome= "/home/liveupload/live"; my $jhome= "/home/liveupload/jorge"; my $httpdlivelog = "/var/log/proftpd/live-http.log"; my $jorgelog = "/var/log/proftpd/jorge.log"; my $livelog = "/var/log/proftpd/live.log"; my $httpdlivelog_fh; open($httpdlivelog_fh, ">+ $httpdlivelog"); my $livelog_fh; open($livelog_fh, ">+ $livelog"); my $jorgelog_fh; open($jorgelog_fh, ">+ $jorgelog"); unless (-p $fifo_file) { unlink $fifo_file; system('mknod', $fifo_file, 'p') && die "can't mknod $fifo_file: $!"; system('chmod', '666', $fifo_file) && die "can't chown $fifo_file: $!"; } my $fifo_fh; open($fifo_fh, "+< $fifo_file") or die "The FIFO file \"$fifo_file\" is missing, and this program can't run without it.:$!"; setlogsock 'unix'; openlog($program, 'pid', $syslog_facility); while (my $lines = <$fifo_fh>) { chomp $lines; if ($lines eq $hlhome) { print $httpdlivelog_fh "$lines\n"; } elsif ($lines eq $lhome) { print $livelog_fh "$lines\n"} elsif ($lines eq $jhome) { print $jorgelog_fh "$lines\n";} else { print "The destination folder is invalid\n"; } } closelog(); close $fifo_fh; As of now the script shows no perl errors, and seems to run. However, it only displays the else option, saying invalid folders. The folder uploaded is correct, so I'm guessing it's actually the "chomp $lines;" and parsing of the $lines syntax. Still have not gotten it to run correctly.
|