<?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: script wanted in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090476#M310252</link>
    <description>thx all&lt;BR /&gt;&lt;BR /&gt;If I want the mail is only send when the word "error" is exist , that mean if no error then don't send the mail , can advise what can i do ? thx</description>
    <pubDate>Thu, 25 Oct 2007 05:29:25 GMT</pubDate>
    <dc:creator>ust3</dc:creator>
    <dc:date>2007-10-25T05:29:25Z</dc:date>
    <item>
      <title>script wanted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090472#M310248</link>
      <description>Hi ,&lt;BR /&gt;I am not familiar with writing script , if I want to check a directory , to find out all the file that the files are&lt;BR /&gt;1. contains a word "shutdown" ( any Block or small letter ) ,&lt;BR /&gt;2. not elder than 3 days ,&lt;BR /&gt;&lt;BR /&gt;then send mail with the file name and the whole phase of the shutdown statement .&lt;BR /&gt;&lt;BR /&gt;can advise how to write the script . &lt;BR /&gt;thx in advance.&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Oct 2007 05:32:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090472#M310248</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2007-10-23T05:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: script wanted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090473#M310249</link>
      <description>#!/usr/bin/sh&lt;BR /&gt; &lt;BR /&gt;set -u&lt;BR /&gt;export PATH=/usr/bin&lt;BR /&gt;MYDIR=/changeMEtoYOURdir&lt;BR /&gt;cd $MYDIR &lt;BR /&gt;RTN=$?&lt;BR /&gt;[ $RTN -ne 0 ] &amp;amp;&amp;amp; echo "no permission or no such directory: $MYDIR" &amp;amp;&amp;amp; exit 1&lt;BR /&gt;FILELIST=$(find * -type f -prune -mtime -3)&lt;BR /&gt;[ -z "$FILELIST" ] &amp;amp;&amp;amp; echo "no files less than 4 days old" &amp;amp;&amp;amp; exit 2&lt;BR /&gt;SDLIST=$(grep -i shutdown $FILELIST)&lt;BR /&gt;COUNT=$(echo "$SDLIST" |  wc -l)&lt;BR /&gt;[ $COUNT -eq 0 ] &amp;amp;&amp;amp; SDLIST="none found"&lt;BR /&gt;[ $COUNT -eq 1 ] &amp;amp;&amp;amp; SDLIST=$FILELIST:$SDLIST&lt;BR /&gt;&lt;BR /&gt;echo "$SDLIST" | mailx -s "$COUNT file(s) found with shutdown" your_name@cpu.com</description>
      <pubDate>Tue, 23 Oct 2007 06:33:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090473#M310249</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2007-10-23T06:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: script wanted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090474#M310250</link>
      <description>hi&lt;BR /&gt;i think its not very comlicated. I wrote a simple shell script that you can try.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;PATH=searching_path&lt;BR /&gt;N=number_of_days&lt;BR /&gt;TEXT=word_you_are_searching&lt;BR /&gt;FILE=file_where_you_writing results&lt;BR /&gt;EMAIL=email_address_where_you_send_results&lt;BR /&gt;&lt;BR /&gt;find $PATH -type f -ctime -$N | xargs grep -i $TEXT &amp;gt; $FILE&lt;BR /&gt;&lt;BR /&gt;mail -s "SUBJECT" $EMAIL &amp;lt; $FILE</description>
      <pubDate>Tue, 23 Oct 2007 06:46:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090474#M310250</guid>
      <dc:creator>Erol KAHRAMAN</dc:creator>
      <dc:date>2007-10-23T06:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: script wanted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090475#M310251</link>
      <description>I believe by "phase" you mean the contents of the file with the word shutdown in it.  Since you are new to scripting, I'll be very explicit in wording and commands so you can replicate and learn.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;PATH="/bin:/usr/bin"&lt;BR /&gt;MYDIR="/directory/you/want/to/scan"&lt;BR /&gt;# make sure we have the directory&lt;BR /&gt;if [ -d $MYDIR ] ; then&lt;BR /&gt; cd $MYDIR&lt;BR /&gt; if [ $? -ne 0 ] ; then&lt;BR /&gt;   echo "could not cd to $MYDIR" ; exit 11&lt;BR /&gt; fi&lt;BR /&gt;else&lt;BR /&gt; echo "no such directory $MYDIR" ; exit 2&lt;BR /&gt;fi&lt;BR /&gt;# make a list of files&lt;BR /&gt;FILES=`find . -mtime -3 -type f -print 2&amp;gt;&amp;gt;/dev/null |grep -i shutdown`&lt;BR /&gt;# Do nothing if we have nothing&lt;BR /&gt;if [ "${FILES}x" = "x" ] ; then&lt;BR /&gt;  echo "No files to process"&lt;BR /&gt;else&lt;BR /&gt;TMP="/tmp/my.mailfile.txt"&lt;BR /&gt;for FILE in $FILES ; do&lt;BR /&gt;echo "$FILE" &amp;gt;&amp;gt;$TMP &lt;BR /&gt;cat $FILE &amp;gt;&amp;gt;$TMP&lt;BR /&gt;echo "" &amp;gt;&amp;gt;$TMP ; echo "" &amp;gt;&amp;gt;$TMP&lt;BR /&gt;done&lt;BR /&gt;cat $TMP |mailx -s "shutdown requests" youraddr@somewhere.net&lt;BR /&gt;rm $TMP&lt;BR /&gt;fi</description>
      <pubDate>Tue, 23 Oct 2007 14:05:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090475#M310251</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2007-10-23T14:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: script wanted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090476#M310252</link>
      <description>thx all&lt;BR /&gt;&lt;BR /&gt;If I want the mail is only send when the word "error" is exist , that mean if no error then don't send the mail , can advise what can i do ? thx</description>
      <pubDate>Thu, 25 Oct 2007 05:29:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090476#M310252</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2007-10-25T05:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: script wanted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090477#M310253</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;change the 'else' part of ShannonÃ s solution to:&lt;BR /&gt;...&lt;BR /&gt;else&lt;BR /&gt; TMP="/tmp/my.mailfile.txt"&lt;BR /&gt; SEARCH4=error&lt;BR /&gt; for FILE in $FILES ; do&lt;BR /&gt;  if fgrep $SEARCH4 $FILE &amp;gt;/dev/null&lt;BR /&gt;  then &lt;BR /&gt;   print "\n$FILE"&lt;BR /&gt;   print "================="&lt;BR /&gt;   cat $FILE&lt;BR /&gt;  fi&lt;BR /&gt; done &amp;gt;$TMP&lt;BR /&gt; if [ -s $TMP ]&lt;BR /&gt; then&lt;BR /&gt;  mailx -s "shutdown requests" youraddr@somewhere.net &amp;lt;$TMP&lt;BR /&gt; fi&lt;BR /&gt; rm $TMP&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Thu, 25 Oct 2007 07:17:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090477#M310253</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-10-25T07:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: script wanted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090478#M310254</link>
      <description>Thx replies .&lt;BR /&gt;&lt;BR /&gt;My script is simple as below  , it works find now ..&lt;BR /&gt;&lt;BR /&gt;find /ora/output/ -type f -mtime -2 | xargs grep -i "error" &amp;gt; $FILE&lt;BR /&gt;cat $FILE &amp;gt;&amp;gt;  $mailfile&lt;BR /&gt;echo "System checking"  &amp;gt;&amp;gt;  $mailfile &lt;BR /&gt;mail -f "admin@my.com" -s "System Checking" user@my.com &amp;lt; $mailfile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now , I would like to have a more request &lt;BR /&gt;&lt;BR /&gt;1. I will run this script three times a day , so user will receive the same error statement six times even they have fixed the error , I would like if the error statement has already sent to the user , then it will NOT send the same error statement again , that means user will receive the same error statement one time only ;&lt;BR /&gt;&lt;BR /&gt;2. if no error then don't send the mail to user &lt;BR /&gt;&lt;BR /&gt;can advise what can I do ? Thx in advance.</description>
      <pubDate>Thu, 25 Oct 2007 22:11:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090478#M310254</guid>
      <dc:creator>ust3</dc:creator>
      <dc:date>2007-10-25T22:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: script wanted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090479#M310255</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;regarding 2)&lt;BR /&gt;I gave already a solution:&lt;BR /&gt;...&lt;BR /&gt; done &amp;gt;$TMP&lt;BR /&gt;if [ -s $TMP ]&lt;BR /&gt;then&lt;BR /&gt;  mailx -s "shutdown requests" youraddr@somewhere.net &amp;lt;$TMP&lt;BR /&gt;fi&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;reagarding 1)&lt;BR /&gt;Simplest solution: keep the last result and compare against this:&lt;BR /&gt;...&lt;BR /&gt; done &amp;gt;$TMP&lt;BR /&gt;if [ -s $TMP ]&lt;BR /&gt;then&lt;BR /&gt;  if [ -s $TMP.last ] &amp;amp;&amp;amp; cmp -s $TMP $TMP.lst&lt;BR /&gt;  then rm $TMP&lt;BR /&gt;  else&lt;BR /&gt;   mailx -s "shutdown requests" youraddr@somewhere.net &amp;lt;$TMP&lt;BR /&gt;   mv $TMP $TMP.last&lt;BR /&gt;  fi&lt;BR /&gt;else rm $TMP&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Oct 2007 03:04:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-wanted/m-p/4090479#M310255</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-10-26T03:04:29Z</dc:date>
    </item>
  </channel>
</rss>

