Perl Check - Need Help
Shawn Iverson
iversons at rushville.k12.in.us
Sat Apr 8 11:10:09 UTC 2017
Hi Jerry,
Just looked over your code. It looks straightforward and complete to me.
My only question I may have is "/var/spool/postfix/public/qmgr" being hard
coded. Is it possible for this path to vary depending on the postfix
configuration on other systems?
On Sat, Apr 8, 2017 at 1:52 AM, Jerry Benton <jerry.benton at mailborder.com>
wrote:
> One last update to remove useless line.
>
>
> use IO::Socket::UNIX;
>
> sub KickMessage {
> my($queue2ids, $sendmail2) = @_;
> my($queue);
>
> # Do a kick for every queue that contains some message ids
> foreach $queue (keys %$queue2ids) {
> next unless $queue2ids->{$queue};
>
> my $pf_connection = '/var/spool/postfix/public/qmgr';
>
> if(-S $pf_connection){
> # UNIX
> my $fh = IO::Socket::UNIX->new(
> Type => SOCK_STREAM,
> Peer => $pf_connection,
> ) or
> MailScanner::Log::WarnLog("KickMessage coould not write to UNIX >
> $pf_connection");
> print $fh "I";
> close $fh;
> }elsif(-p $pf_connection){
> # FIFO
> open(my $fh, '>', $pf_connection) or
> MailScanner::Log::WarnLog("KickMessage coould not write to FIFO >
> $pf_connection");
> print $fh "I";
> close $fh;
> }else{
> MailScanner::Log::WarnLog("Unable to determine socket type (FIFO/UNIX)
> > $pf_connection");
> }
> }
> return 0;
> }
>
>
> -
> Jerry Benton
> www.mailborder.com
> +1 - 844-436-6245 <(844)%20436-6245>
>
>
>
> On Apr 8, 2017, at 1:46 AM, Jerry Benton <jerry.benton at mailborder.com>
> wrote:
>
> I have it working under both FIFO and UNIX, so I guess I did it right.
> Final code for record keeper’s sake:
>
>
> use IO::Socket::UNIX;
>
> sub KickMessage {
> my($queue2ids, $sendmail2) = @_;
> my($queue);
>
> # Do a kick for every queue that contains some message ids
> foreach $queue (keys %$queue2ids) {
> next unless $queue2ids->{$queue};
>
> my $pf_connection = '/var/spool/postfix/public/qmgr';
>
> if(-S $pf_connection){
> # UNIX
> my $fh = IO::Socket::UNIX->new(
> Type => SOCK_STREAM,
> Peer => $pf_connection,
> ) or
> MailScanner::Log::WarnLog("KickMessage coould not write to UNIX >
> $pf_connection");
> print $fh "I";
> close $fh;
> }elsif(-p $pf_connection){
> # FIFO
> my $fh = new FileHandle;
> open(my $fh, '>', $pf_connection) or
> MailScanner::Log::WarnLog("KickMessage coould not write to FIFO >
> $pf_connection");
> print $fh "I";
> close $fh;
> }else{
> MailScanner::Log::WarnLog("Unable to determine socket type (FIFO/UNIX)
> > $pf_connection");
> }
> }
> return 0;
> }
>
>
> -
> Jerry Benton
> www.mailborder.com
> +1 - 844-436-6245 <(844)%20436-6245>
>
>
>
> On Apr 7, 2017, at 6:58 PM, Jerry Benton <jerry.benton at mailborder.com>
> wrote:
>
> I am trying to update some Perl code that checks if a socket is FIFO or
> UNIX and then executes appropriately. I am not entirely sure about the UNIX
> socket I am creating here. Can any Perl gurus chime in?
>
> use IO::Socket::UNIX;
>
>
> my $pf_connection = '/var/spool/postfix/public/qmgr';
> if(-p $pf_connection){
> # FIFO
> my $fh = new FileHandle;
> $fh->open($pf_connection) or
> MailScanner::Log::WarnLog("KickMessage coould not write to FIFO " .
> "%s, %s", "$public/qmgr", $!);
> print $fh "I";
> $fh->close;
> }elsif(-S $pf_connection){
> # UNIX
> my $fh = IO::Socket::UNIX->new(
> Type => SOCK_STREAM,
> Peer => $pf_connection,
> ) or
> MailScanner::Log::WarnLog("KickMessage coould not write to UNIX " .
> "%s, %s", "$public/qmgr", $!);
> print $fh "I";
> $fh->close;
> }else{
> MailScanner::Log::WarnLog("Unable to determine socket type (FIFO/UNIX)
> " .
> "%s, %s", "$public/qmgr", $!);
> }
>
>
>
> -
> Jerry Benton
> www.mailborder.com
> +1 - 844-436-6245 <(844)%20436-6245>
>
>
>
>
>
>
>
>
> --
> MailScanner mailing list
> mailscanner at lists.mailscanner.info
> http://lists.mailscanner.info/mailman/listinfo/mailscanner
>
>
>
--
Shawn Iverson
Director of Technology
Rush County Schools
765-932-3901 x271
iversons at rushville.k12.in.us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mailscanner.info/pipermail/mailscanner/attachments/20170408/bb84d19a/attachment.html>
More information about the MailScanner
mailing list