<?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 Script for checking in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108557#M312880</link>
    <description>I have below script to check the word in the driectory /ora_tmp , there are many files in this directory ,  if the word "error" is exist in any file within 5 day , then send the mail to ora-usr@mydomain.com about which file have this word and the "error" statement , now , if I want &lt;BR /&gt;&lt;BR /&gt;1. if there is no "error" word existed in any file , then DO NOT send the mail ;&lt;BR /&gt;2. send  "error"  statement to user one time only , that mean , only inform user the "error" statement one time , if there are same "error" statement within 5 days , send the mail to user one time only ( the user need to know the same error one time only ) . can advise how can I  change it ? thx.&lt;BR /&gt;&lt;BR /&gt;FILE=/tmp/error ; export FILE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;mailfile=/tmp/mailfile ; export mailfile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;find /ora_tmp  -type f -mtime -5 -maxdepth 1 | xargs grep -i "error" &amp;gt; $FILE&lt;BR /&gt;&lt;BR /&gt;cat $FILE &amp;gt;&amp;gt;  $mailfile&lt;BR /&gt;&lt;BR /&gt;echo $mailfile&lt;BR /&gt;mail ora-usr@mydomain.com  &amp;lt; $mailfile</description>
    <pubDate>Tue, 27 Nov 2007 21:15:37 GMT</pubDate>
    <dc:creator>ust3</dc:creator>
    <dc:date>2007-11-27T21:15:37Z</dc:date>
    <item>
      <title>Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108557#M312880</link>
      <description>I have below script to check the word in the driectory /ora_tmp , there are many files in this directory ,  if the word "error" is exist in any file within 5 day , then send the mail to ora-usr@mydomain.com about which file have this word and the "error" statement , now , if I want &lt;BR /&gt;&lt;BR /&gt;1. if there is no "error" word existed in any file , then DO NOT send the mail ;&lt;BR /&gt;2. send  "error"  statement to user one time only , that mean , only inform user the "error" statement one time , if there are same "error" statement within 5 days , send the mail to user one time only ( the user need to know the same error one time only ) . can advise how can I  change it ? thx.&lt;BR /&gt;&lt;BR /&gt;FILE=/tmp/error ; export FILE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;mailfile=/tmp/mailfile ; export mailfile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;find /ora_tmp  -type f -mtime -5 -maxdepth 1 | xargs grep -i "error" &amp;gt; $FILE&lt;BR /&gt;&lt;BR /&gt;cat $FILE &amp;gt;&amp;gt;  $mailfile&lt;BR /&gt;&lt;BR /&gt;echo $mailfile&lt;BR /&gt;mail ora-usr@mydomain.com  &amp;lt; $mailfile</description>
      <pubDate>Tue, 27 Nov 2007 21:15:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108557#M312880</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2007-11-27T21:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108558#M312881</link>
      <description>&lt;!--!*#--&gt;One way would be to have 6 files.  Each day you would move the files one older:&lt;BR /&gt;mv ${FILE}.4 ${FILE}.5&lt;BR /&gt;...&lt;BR /&gt;mv ${FILE}.0 ${FILE}.1&lt;BR /&gt;&lt;BR /&gt;(To prime the pump, create 5 empty files.)&lt;BR /&gt;&lt;BR /&gt;Then do the find ... grep to ${FILE}.0&lt;BR /&gt;&lt;BR /&gt;After this step, you would remove all lines that were in ${FILE}.1 ... ${FILE}.5&lt;BR /&gt;sort -u ${FILE}.[1-5] &amp;gt; ${FILE}.ALL&lt;BR /&gt;fgrep -v -f ${FILE}.ALL ${FILE}.0 &amp;gt; $mailfile&lt;BR /&gt;rm -f ${FILE}.ALL&lt;BR /&gt;&lt;BR /&gt;(I'm assuming ${FILE}.ALL isn't too big or the performance of the script isn't important.)&lt;BR /&gt;&lt;BR /&gt;Note: There is no need to export FILE and mailfile if you aren't reading them in some other script.&lt;BR /&gt;&lt;BR /&gt;If the same error re-occurs after 5 days, it will be re-sent.  If it goes away and then comes back in two days, it won't be re-sent.&lt;BR /&gt;&lt;BR /&gt;1) only send if $mailfile has errors&lt;BR /&gt;if [ -s $mailfile ]; then&lt;BR /&gt;   mailx -s "Error messags" ora-usr@mydomain.com &amp;lt; $mailfile&lt;BR /&gt;fi</description>
      <pubDate>Wed, 28 Nov 2007 05:26:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108558#M312881</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-11-28T05:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108559#M312882</link>
      <description>thx reply ,&lt;BR /&gt;&lt;BR /&gt;I modified the script as below , it can send nodify mail only when there is error ,&lt;BR /&gt;but I am not too understand the suggestion above , my requirement is " to send "error" statement to user one time only , that mean , only inform user the "error" statement one time , if there are same "error" statement within 5 days , send the mail to user one time only ( the user need to know the same error one time only ) . can advise ? thx&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;FILE=/tmp/error ; export FILE&lt;BR /&gt;mailfile=/tmp/mailfile ; export mailfile&lt;BR /&gt;find /ora_tmp -type f -mtime -5 -maxdepth 1 | xargs grep -i "error" &amp;gt; $FILE&lt;BR /&gt;if [ -s $FILE ] ;  then&lt;BR /&gt;cat $FILE &amp;gt;&amp;gt; $mailfile&lt;BR /&gt;echo $mailfile&lt;BR /&gt;mail ora-usr@mydomain.com &amp;lt; $mailfile &lt;BR /&gt;</description>
      <pubDate>Tue, 11 Dec 2007 03:20:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108559#M312882</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2007-12-11T03:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108560#M312883</link>
      <description>&amp;gt;I modified the script as below, it can send modify mail only when there is error,&lt;BR /&gt;&lt;BR /&gt;(I assume there is a "fi" to go with the "if".)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;my requirement is "to send error statement to user one time only", that mean, only inform user the "error" statement one time, if there are same "error" statement within 5 days, send the mail to user one time only (the user need to know the same error one time only).&lt;BR /&gt;&lt;BR /&gt;Currently my suggested code sends the error only once, in 5 days.  If you want to turn the error back on after 5 days, you would have to fiddle with the 5 error "caches".&lt;BR /&gt;&lt;BR /&gt;Basically, you need more words to describe what you want.  I.e. a concrete example.&lt;BR /&gt;&lt;BR /&gt;You could explain what you want for all 2**5 == 32 cases of one error either there or not, for 5 days.  :-)&lt;BR /&gt;But I don't need that many cases.</description>
      <pubDate>Tue, 11 Dec 2007 04:26:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108560#M312883</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-11T04:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108561#M312884</link>
      <description>thx reply,&lt;BR /&gt;&lt;BR /&gt;what my requirement is find the word "error" in the directory ( I will schedule it to run 3 hour/day ) , if there is "error" within 5 days then send the mail ( includes the file name ) to inform the administrator , BUT only send the same file name to admin one time .&lt;BR /&gt;&lt;BR /&gt;for example , the oracle db generate the error to /tmp time by time , I would like to fix the error once it is happened , but if the error is not fixed yet over 3 hours , then NO NEED to send the same error to administrator , that mean administrator only receive the same error one time . can advise what can i do ? thx</description>
      <pubDate>Tue, 25 Dec 2007 01:31:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108561#M312884</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2007-12-25T01:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108562#M312885</link>
      <description>in the directory , there are many files , each file have many lines , if the applicatin have bug , it will generate the error to file , so some files have a word "error" ,</description>
      <pubDate>Tue, 25 Dec 2007 01:58:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108562#M312885</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2007-12-25T01:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108563#M312886</link>
      <description>thx all ,&lt;BR /&gt;&lt;BR /&gt;please ignore the problem .</description>
      <pubDate>Tue, 25 Dec 2007 02:36:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108563#M312886</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2007-12-25T02:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108564#M312887</link>
      <description>sorry to ask again.&lt;BR /&gt;&lt;BR /&gt;I would like to state my question again ,  the oracle is continuely generate some file to /tmp , some of file have error statement in it as below.&lt;BR /&gt;&lt;BR /&gt;$ls /tmp&lt;BR /&gt;file1 file2 file3&lt;BR /&gt;&lt;BR /&gt;$vi /tmp/file1&lt;BR /&gt;error:the amount is not correct&lt;BR /&gt;error:integer problem&lt;BR /&gt;&lt;BR /&gt;$vi /tmp/file2&lt;BR /&gt;error:update problem&lt;BR /&gt;&lt;BR /&gt;$vi /tmp/file3&lt;BR /&gt;error:exceed no. of input&lt;BR /&gt;&lt;BR /&gt;what I want is to find which files have error in it and send a mail to administrator to inform the error is exist ( the mail have file name and the error statement ) , I will set a crontab job to check it in every 3 hours , but only send the mail one time if the same error, that mean only send a same error to administratior one time , can advise what can i do ? thx&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 31 Dec 2007 03:04:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108564#M312887</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2007-12-31T03:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108565#M312888</link>
      <description>&lt;!--!*#--&gt;# find which files have error in it&lt;BR /&gt;grep -ni error /tmp/file* &amp;gt; ${FILE}.0&lt;BR /&gt;&lt;BR /&gt;# remove errors from before, includes file, line # and message&lt;BR /&gt;touch ${FILE}.ERR&lt;BR /&gt;fgrep -v -f ${FILE}.ERR ${FILE}.0 &amp;gt; $mailfile&lt;BR /&gt;# save new errors&lt;BR /&gt;sort -u -o ${FILE}.ERR ${FILE}.ERR ${FILE}.0&lt;BR /&gt;rm -f ${FILE}.0&lt;BR /&gt;# only send if $mailfile has errors&lt;BR /&gt;(copy from above)</description>
      <pubDate>Mon, 31 Dec 2007 05:37:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108565#M312888</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-31T05:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108566#M312889</link>
      <description>&lt;!--!*#--&gt;&amp;gt;&amp;gt; but only send the mail one time if the same error, that mean only send a same error to administratior one time&lt;BR /&gt;&lt;BR /&gt;One time per check cycle?&lt;BR /&gt;One time per file checked?&lt;BR /&gt;One time for all files checked?&lt;BR /&gt;&lt;BR /&gt;Anyway, please find below a working skeleton perl solution which surely can readily be adapted to more detailed needs.&lt;BR /&gt;Give it a whirl?&lt;BR /&gt;&lt;BR /&gt;[hint: after a first round of testing there will be a 'marker' file. So to re-test you may want to 'touch' a few error files.]&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;my $DIR = "/tmp/hein";&lt;BR /&gt;my $MARK = $DIR."/error_check_marker";&lt;BR /&gt;my $OPER = "hein";&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;my $file;&lt;BR /&gt;my %errors_seen;&lt;BR /&gt;&lt;BR /&gt;my $last_time = -M $MARK;&lt;BR /&gt;$last_time = 9999 unless $last_time;&lt;BR /&gt;open (MARK, "&amp;gt;$MARK") or die "Could not touch $MARK";&lt;BR /&gt;close MARK;  # new modified time stamp&lt;BR /&gt;&lt;BR /&gt;foreach $file (glob $DIR."/*") {&lt;BR /&gt;   next if $last_time &amp;lt; -M $file; # been there done that?&lt;BR /&gt;   if (open (FILE, "&amp;lt;$file")) {&lt;BR /&gt;      $file =~ s/$DIR\///;&lt;BR /&gt;      while (&lt;FILE&gt;) {&lt;BR /&gt;         chomp;&lt;BR /&gt;         next unless /^error:/;&lt;BR /&gt;         if (defined $errors_seen{$'}) {&lt;BR /&gt;           $errors_seen{$'} .= ",$file";&lt;BR /&gt;         } else {&lt;BR /&gt;           $errors_seen{$'} = $file;&lt;BR /&gt;         }&lt;BR /&gt;      }&lt;BR /&gt;      close FILE;&lt;BR /&gt;   } else {&lt;BR /&gt;      print STDERR "Could not open $file $!\n";&lt;BR /&gt;   }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;if (%errors_seen) {&lt;BR /&gt;  open (MAIL, "| mailx -s \"Error report\" $OPER") or die "Could not create Email";&lt;BR /&gt;  printf MAIL "Found the following errors in recent file in $DIR\n";&lt;BR /&gt;  foreach (sort keys %errors_seen) {&lt;BR /&gt;    printf MAIL "%25s : %s\n", $_, $errors_seen{$_};&lt;BR /&gt;  }&lt;BR /&gt;  close MAIL;&lt;BR /&gt;}&lt;BR /&gt;&lt;/FILE&gt;</description>
      <pubDate>Mon, 31 Dec 2007 05:47:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108566#M312889</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-12-31T05:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Script for checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108567#M312890</link>
      <description>btw, my scripts ignores the 5 day requirement, replacing with a 'new' error in this cycle. It Assumes the error files are created from scratch. If there are appended to then it gets trickier as an old message with remain. You would almost need to remember file, and line number for an error seen, to do that properly. Something similar (or the same as) Dennis's approach would be better for that, as with can remember whcih file, which line.&lt;BR /&gt;My approach could be augmented by making the 'marker file' retain a list of which errors seen and when.&lt;BR /&gt;On startup read the file and discard any marker error older that 5 days. Then only stash those errors in the errors_seen array which were not still in the marker file.&lt;BR /&gt;Update the marker fiel from the old data plus the fresh errors.&lt;BR /&gt;SMOP!&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 31 Dec 2007 06:03:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-checking/m-p/4108567#M312890</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-12-31T06:03:04Z</dc:date>
    </item>
  </channel>
</rss>

