<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:787358026;
mso-list-type:hybrid;
mso-list-template-ids:266368606 -2008879096 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:.75in;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:1.25in;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
margin-left:1.75in;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:2.25in;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:2.75in;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
margin-left:3.25in;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:3.75in;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:4.25in;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
margin-left:4.75in;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Looking for a better way!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This is what I have done so far. I created the following Perl script which connects to a foreign data to determine if there are any available agents login to the phone system.<o:p></o:p></p>
<p class="MsoNormal">If there are agents to send messages to then run getmail to retrieve the messages. It also makes sure the Getmail process is not already running.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Why do I want something better <o:p></o:p></p>
<p class="MsoListParagraph" style="margin-left:.75in;text-indent:-.25in;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>I get the following error when this runs. But messages appear to be delivered.<o:p></o:p></p>
<pre style="margin-left:1.25in;text-indent:-.25in;mso-list:l0 level2 lfo1"><![if !supportLists]><span style="mso-list:Ignore">a.<span style="font:7.0pt "Times New Roman""> </span></span><![endif]>Delivery error (command rt-mailgate 9285 wrote to stderr: cannot chdir to /root from /tmp/VurewGNWhm: Permission denied, aborting. at /usr/lib/perl5/5.16.2/File/Temp.pm line 902.)<o:p></o:p></pre>
<pre style="margin-left:1.25in;text-indent:-.25in;mso-list:l0 level2 lfo1"><![if !supportLists]><span style="mso-list:Ignore">b.<span style="font:7.0pt "Times New Roman""> </span></span><![endif]> msg 575/594 (85001 bytes), delivery error (command rt-mailgate 9285 wrote to stderr: cannot chdir to /root from /tmp/VurewGNWhm: Permission denied, aborting. at /usr/lib/perl5/5.16.2/File/Temp.pm line 902.)<o:p></o:p></pre>
<pre style="margin-left:.75in;text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="mso-list:Ignore">2.<span style="font:7.0pt "Times New Roman""> </span></span><![endif]>I continue to get all kinds of directories left behind in the /tmp directory.<o:p></o:p></pre>
<pre style="margin-left:.75in;text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="mso-list:Ignore">3.<span style="font:7.0pt "Times New Roman""> </span></span><![endif]>I am a newbe and know there has to be a better way.<o:p></o:p></pre>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Script being ran by cron as “root”<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">#!/usr/bin/perl -w<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">use DBI;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">use DateTime;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $host = '192.168.254.10';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $port = '4308';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $database = '';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $user = '';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $password = '';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $command2 = " ";<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $currentID = $$;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $dt = DateTime->now;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">open(FILE, "ps aux|");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">while (<FILE>)
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">(my $uid,my $pid,my $cpu,my $mem,my $vsz,my $rss,my $tty,my $stat,my $start,my $time,my $command,my $command1,my $command2) = split;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">$command = $command // "Unknown";<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">$command = $command1 // "Unknown";<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">$command = $command2 // "Unknown";<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $result = index($command, "/usr/bin/getmail");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">if ($pid ne $currentID)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> if ($result > -1)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> print "$dt Scrip already running $command $pid $currentID $result\n";<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> exit;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $dsn = "DBI:mysql:database=$database;host=$host;port=$port ";<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $dbh = DBI->connect($dsn, $user, $password);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $sql = 'SELECT tabaddress.EmailAddress FROM shoreware.ports as Ports ';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">$sql = $sql . 'inner join (shoreware.usercurrentswitch as UCS) on (Ports.PortID = UCS.HomePortID) ' ;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">$sql = $sql . 'inner join (shoreware.users as Users) on (Ports.CurrentDN = Users.UserDN) ';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">$sql = $sql . 'inner join (shoreware.workgroupagents as Agents) on (Users.UserDN = Agents.UserDN) ';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">$sql = $sql . 'inner join (shoreware.Tabaddresses as tabaddress) on (Users.AddressID = tabaddress.AddressID) ';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">$sql = $sql . 'Where (Ports.JackNumber not like \'%norr%\' or Ports.JackNumber is null and Agents.agentstateID<>0) ';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">$sql = $sql . 'order by Agents.UserDN ';<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $sth = $dbh->prepare($sql);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">$sth->execute;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">my $rows = $sth->rows;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">if ($rows > 0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> system("cd /tmp");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> system("getmail");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> print "$dt Number of rows $rows\n";<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Getmail configuration<o:p></o:p></p>
<pre>[retriever]<o:p></o:p></pre>
<pre>#type = SimpleIMAPSSLRetriever<o:p></o:p></pre>
<pre>#server = imap.gmail.com<o:p></o:p></pre>
<pre>#port = 993<o:p></o:p></pre>
<pre>#username = testcopesan@gmail.com<o:p></o:p></pre>
<pre>#password = <o:p></o:p></pre>
<pre>#mailboxes = ('BBaker',)<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>type = SimpleIMAPRetriever<o:p></o:p></pre>
<pre>server = 192.168.250.61<o:p></o:p></pre>
<pre>port = 143<o:p></o:p></pre>
<pre>username = clientservice@copesan.local<o:p></o:p></pre>
<pre>password = <o:p></o:p></pre>
<pre>mailboxes = ('To_Request_Tracker',)<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>[destination]<o:p></o:p></pre>
<pre>type = MDA_external<o:p></o:p></pre>
<pre>path = /usr/bin/rt-mailgate<o:p></o:p></pre>
<pre>user = rtuser<o:p></o:p></pre>
<pre>group = rtgroup<o:p></o:p></pre>
<pre>arguments = ("--url", "http://localhost/rt", "--queue", "x CSR", "--action", "correspond",)<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>[options]<o:p></o:p></pre>
<pre>read_all = false<o:p></o:p></pre>
<pre>delete = false<o:p></o:p></pre>
<pre>received = false<o:p></o:p></pre>
<pre>delivered_to = false<o:p></o:p></pre>
<pre>message_log = /var/log/request-tracker/mvmail.log<o:p></o:p></pre>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks in advance for all the help.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Bryon Baker<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Network Operations Manager<o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">Copesan</span></i></b><b><i><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black"> - Specialists in Pest Solutions<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">800-267-3726 • 262-783-6261 ext. 2296<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><a href="mailto:cstephan@copesan.com"><span style="color:blue">bbaker@copesan.com</span></a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black"><a href="http://www.copesan.com/"><span style="color:black">www.copesan.com</span></a><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:red">"Servicing North America with Local Care"</span></i></b><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>