<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help to re-write a perl script. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-to-re-write-a-perl-script/m-p/3151732#M157673</link>
    <description>You guys are great! I really appreciate all your help. Thanks again and have a safe a happy holidays to all of you.&lt;BR /&gt;&lt;BR /&gt;Reynaldo.</description>
    <pubDate>Tue, 23 Dec 2003 12:11:26 GMT</pubDate>
    <dc:creator>Reynaldo Torres</dc:creator>
    <dc:date>2003-12-23T12:11:26Z</dc:date>
    <item>
      <title>Help to re-write a perl script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-to-re-write-a-perl-script/m-p/3151729#M157670</link>
      <description>Good morning all, and happy holidays. I would like to get some help to re-write a perl script, which currently is setup as a pager alert for some of my mount points in my UNIX HP9000 K570, but now I have the need for e-mail as well. If anyone could assist me on this, I will really appreciated, and I will give points to the best respond. The following script is the one that I have running as a pager alert. This script was written by someone else, I am not an expert writing perl scripts, so I would like to get the right syntax for it. &lt;BR /&gt;&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;&lt;BR /&gt;RT.&lt;BR /&gt;&lt;BR /&gt;#!/usr/contrib/bin/perl&lt;BR /&gt;&lt;BR /&gt;# Usage: dfstat&lt;BR /&gt;&lt;BR /&gt;$dfcmd="/usr/bin/bdf";&lt;BR /&gt;$pagepgm="/etc/pager";&lt;BR /&gt;$pagepin="2377725";&lt;BR /&gt;&lt;BR /&gt;$warnpct=90;&lt;BR /&gt;$msg="";&lt;BR /&gt;$msgcnt=0;&lt;BR /&gt;&lt;BR /&gt;open(DF, "$dfcmd|") || die "can't run $dfcmd: $!";&lt;BR /&gt;$title=&lt;DF&gt;;&lt;BR /&gt;#print TTYOUT $title;&lt;BR /&gt;&lt;BR /&gt;# Catch any errors with eval.  A bad pattern, for instance.&lt;BR /&gt;&lt;BR /&gt;eval &amp;lt;&amp;lt;'EOF';&lt;BR /&gt;while ($buf=&lt;DF&gt;) {&lt;BR /&gt;    chop($buf);&lt;BR /&gt;    ($filesys, $kbytes, $used, $avail, $usedpct, $mountpt)=split(' ', $buf);&lt;BR /&gt;    chop($usedpct);&lt;BR /&gt;    next if (($mountpt ne "/") &amp;amp;&amp;amp; ($mountpt ne "/var") &amp;amp;&amp;amp; ($mountpt ne "/usr") &amp;amp;&amp;amp; ($mountpt ne "/u112") &amp;amp;&amp;amp; ($mountpt ne "/tmp") &amp;amp;&amp;amp; ($mountpt ne "/home") &amp;amp;&amp;amp; ($mountpt ne "/u113") &amp;amp;&amp;amp; ($mountpt ne "/u61") &amp;amp;&amp;amp; ($mountpt ne "/u52"));&lt;BR /&gt;    if (($mountpt eq "/") &amp;amp;&amp;amp; ($usedpct &amp;gt; 80)) {&lt;BR /&gt;        $msg=$msg . " $mountpt $usedpct%.";&lt;BR /&gt;        $msgcnt++;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if (($mountpt eq "/var") &amp;amp;&amp;amp; ($usedpct &amp;gt; 80)) {&lt;BR /&gt;        $msg=$msg . " $mountpt $usedpct%.";&lt;BR /&gt;        $msgcnt++;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if (($mountpt eq "/tmp") &amp;amp;&amp;amp; ($usedpct &amp;gt; 90)) {&lt;BR /&gt;        $msg=$msg . " $mountpt $usedpct%.";&lt;BR /&gt;        $msgcnt++;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if (($mountpt eq "/usr") &amp;amp;&amp;amp; ($usedpct &amp;gt; 80)) {&lt;BR /&gt;        $msg=$msg . " $mountpt $usedpct%.";&lt;BR /&gt;        $msgcnt++;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if (($mountpt eq "/u112") &amp;amp;&amp;amp; ($usedpct &amp;gt; 85)) {&lt;BR /&gt;        $msg=$msg . " $mountpt $usedpct%.";&lt;BR /&gt;        $msgcnt++;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if (($mountpt eq "/u113") &amp;amp;&amp;amp; ($usedpct &amp;gt; 80)) {&lt;BR /&gt;        $msg=$msg . " $mountpt $usedpct%.";&lt;BR /&gt;        $msgcnt++;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if (($mountpt eq "/u61") &amp;amp;&amp;amp; ($usedpct &amp;gt; 85)) {&lt;BR /&gt;        $msg=$msg . " $mountpt $usedpct%.";&lt;BR /&gt;        $msgcnt++;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if (($mountpt eq "/u52") &amp;amp;&amp;amp; ($usedpct &amp;gt; 80)) {&lt;BR /&gt;        $msg=$msg . " $mountpt $usedpct%.";&lt;BR /&gt;        $msgcnt++;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if (($mountpt eq "/home") &amp;amp;&amp;amp; ($usedpct &amp;gt; 85)) {&lt;BR /&gt;        $msg=$msg . " $mountpt $usedpct%.";&lt;BR /&gt;        $msgcnt++;&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if ($usedpct &amp;gt;= $warnpct) {&lt;BR /&gt;        $msg=$msg . " $mountpt $usedpct%.";&lt;BR /&gt;        $msgcnt++;&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;if ($msgcnt &amp;gt; 0) {&lt;BR /&gt;    $msg="Warning ora2 bdf:" . $msg;&lt;BR /&gt;#    print "$msg\n";&lt;BR /&gt;    &amp;amp;page($pagepin);&lt;BR /&gt;    sleep 120;&lt;BR /&gt;    &amp;amp;page($pagepin);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sub page {&lt;BR /&gt;open(PAGER,"|$pagepgm $_[0]") || die "Couldn't run $pagepgm: $!\n";&lt;BR /&gt;print PAGER "$msg\n";&lt;BR /&gt;close PAGER;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DF&gt;&lt;/DF&gt;</description>
      <pubDate>Tue, 23 Dec 2003 10:39:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-to-re-write-a-perl-script/m-p/3151729#M157670</guid>
      <dc:creator>Reynaldo Torres</dc:creator>
      <dc:date>2003-12-23T10:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help to re-write a perl script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-to-re-write-a-perl-script/m-p/3151730#M157671</link>
      <description>Put the following at the beginning of your script:&lt;BR /&gt;&lt;BR /&gt;#Module used to send the email&lt;BR /&gt;use MIME::Lite;&lt;BR /&gt;&lt;BR /&gt;then put the following code at the bottom, you will obviously have to tweak it so it can email you what you want. I use this script to email reports out to employees. It runs in cron. Obviously the variables defined below would need to be defined somewhere in the middle of the script. I hope this helps! If you need more help to do something more specific, just let me know.&lt;BR /&gt;&lt;BR /&gt;$mime_msg = MIME::Lite-&amp;gt;new( #setup email message&lt;BR /&gt; From    =&amp;gt; $from,&lt;BR /&gt; To  =&amp;gt; $to_address,&lt;BR /&gt; CC =&amp;gt; $reply,&lt;BR /&gt; "Reply-To"=&amp;gt; $reply,&lt;BR /&gt; Subject =&amp;gt; "$newfile - $subject",&lt;BR /&gt; Data =&amp;gt; $message1&lt;BR /&gt; )&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Hazem</description>
      <pubDate>Tue, 23 Dec 2003 11:19:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-to-re-write-a-perl-script/m-p/3151730#M157671</guid>
      <dc:creator>Hazem Mahmoud_3</dc:creator>
      <dc:date>2003-12-23T11:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Help to re-write a perl script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-to-re-write-a-perl-script/m-p/3151731#M157672</link>
      <description>add this (inside your error count test $msgcnt &amp;gt; 0):&lt;BR /&gt;&lt;BR /&gt;open(tmpFILEPTR,"|uuencode text.txt |mailx -m -s'ERROR TITLE HERE' YOURNAME\@YOURDOMAIN.com") || die "ERROR MESSAGE HERE\n";&lt;BR /&gt; &lt;BR /&gt;printf(tmpFILEPTR "%s",$msg);&lt;BR /&gt; &lt;BR /&gt;close(tmpFILEPTR);&lt;BR /&gt; &lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Tue, 23 Dec 2003 11:44:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-to-re-write-a-perl-script/m-p/3151731#M157672</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2003-12-23T11:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Help to re-write a perl script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-to-re-write-a-perl-script/m-p/3151732#M157673</link>
      <description>You guys are great! I really appreciate all your help. Thanks again and have a safe a happy holidays to all of you.&lt;BR /&gt;&lt;BR /&gt;Reynaldo.</description>
      <pubDate>Tue, 23 Dec 2003 12:11:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-to-re-write-a-perl-script/m-p/3151732#M157673</guid>
      <dc:creator>Reynaldo Torres</dc:creator>
      <dc:date>2003-12-23T12:11:26Z</dc:date>
    </item>
  </channel>
</rss>

