<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I have it working under both FIFO and UNIX, so I guess I did it right. Final code for record keeper’s sake:<div class=""><br class=""></div><div class=""><br class=""></div><div class=""> use IO::Socket::UNIX;</div><div class=""><br class=""></div><div class=""><div class=""><div class=""> sub KickMessage {</div><div class=""> my($queue2ids, $sendmail2) = @_;</div><div class=""> my($queue);</div><div class=""><br class=""></div><div class=""> # Do a kick for every queue that contains some message ids</div><div class=""> foreach $queue (keys %$queue2ids) {</div><div class=""> next unless $queue2ids->{$queue};</div><div class=""><br class=""></div><div class=""> my $pf_connection = '/var/spool/postfix/public/qmgr';</div><div class=""> </div><div class=""> if(-S $pf_connection){</div><div class=""> <span class="Apple-tab-span" style="white-space:pre"> </span># UNIX</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span>my $fh = IO::Socket::UNIX->new(</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span> Type => SOCK_STREAM,</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span> Peer => $pf_connection,</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span> ) or</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>MailScanner::Log::WarnLog("KickMessage coould not write to UNIX > $pf_connection");</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>print $fh "I";</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>close $fh;<span class="Apple-tab-span" style="white-space:pre"> </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span> }elsif(-p $pf_connection){</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span># FIFO</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>my $fh = new FileHandle;</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>open(my $fh, '>', $pf_connection) or</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>MailScanner::Log::WarnLog("KickMessage coould not write to FIFO > $pf_connection");</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>print $fh "I";</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>close $fh;</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span> }else{</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span>MailScanner::Log::WarnLog("Unable to determine socket type (FIFO/UNIX) > $pf_connection");</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span> }</div><div class=""> }</div><div class=""> return 0;</div><div class=""> }</div></div><div class=""><br class=""></div><div class="">
<div style="color: rgb(0, 0, 0); font-family: Tahoma; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><br class="">-<br class="">Jerry Benton<br class=""><a href="http://www.mailborder.com" class="">www.mailborder.com</a><br class="">+1 - 844-436-6245<br class=""><br class=""><br class=""></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Apr 7, 2017, at 6:58 PM, Jerry Benton <<a href="mailto:jerry.benton@mailborder.com" class="">jerry.benton@mailborder.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">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? <br class=""><br class="">use IO::Socket::UNIX;<br class=""><br class=""><br class=""> my $pf_connection = '/var/spool/postfix/public/qmgr';<br class=""> if(-p $pf_connection){<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span># FIFO<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>my $fh = new FileHandle;<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>$fh->open($pf_connection) or<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>MailScanner::Log::WarnLog("KickMessage coould not write to FIFO " .<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span> "%s, %s", "$public/qmgr", $!);<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>print $fh "I";<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>$fh->close;<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span> }elsif(-S $pf_connection){<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span># UNIX<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span>my $fh = IO::Socket::UNIX->new(<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span> Type => SOCK_STREAM,<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span> Peer => $pf_connection,<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span> ) or<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>MailScanner::Log::WarnLog("KickMessage coould not write to UNIX " .<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span> "%s, %s", "$public/qmgr", $!);<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>print $fh "I";<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>$fh->close; <span class="Apple-tab-span" style="white-space:pre"> </span><br class=""><span class="Apple-tab-span" style="white-space:pre"> </span> }else{<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span>MailScanner::Log::WarnLog("Unable to determine socket type (FIFO/UNIX) " .<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span> "%s, %s", "$public/qmgr", $!);<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span> }<br class=""><br class=""><br class=""><br class="">-<br class="">Jerry Benton<br class=""><a href="http://www.mailborder.com" class="">www.mailborder.com</a><br class="">+1 - 844-436-6245<br class=""><br class=""><br class=""><br class=""></div></div></blockquote></div><br class=""></div></body></html>