<?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 To pass comments on  a script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647817#M102371</link>
    <description>Hi Guys&lt;BR /&gt;I have this script that runs everyday to Long list (ll in HPUX and ls -la in Solaris)all the files in all the directories.The Script when runs the nextday , captures the difference between previous day's longlist(ll) and currentday longlist (ll) using the diff command in HPUX "diff file1 file2 &amp;gt; file12"] and save it to new file titled "result".&lt;BR /&gt;&lt;BR /&gt;The Result file looks like this &lt;BR /&gt;&lt;BR /&gt;-rw-r--r--  1 root  sys  48  Sep 17 09:32 see &lt;BR /&gt;drwxr-xr-x  3 root  sys  96  Sep 17 08:58 tde5&lt;BR /&gt;drwxr-xr-x  2 root  sys  96  Sep 17 08:57 tse4&lt;BR /&gt;-rw-r--r--  1 root  sys  30  Sep 17 09:32 ree&lt;BR /&gt;&lt;BR /&gt;There are 9 fields in the "result" output file.&lt;BR /&gt;&lt;BR /&gt;Now I want to pass comments (like change in file owner or change in permission) for every file if there is any change in any of the fields of the file.&lt;BR /&gt;&lt;BR /&gt;Can you please suggest me a way to do it and that would fit to my below mentioned script.&lt;BR /&gt;The script is as follows:&lt;BR /&gt;&lt;BR /&gt;#! /usr/bin/sh &lt;BR /&gt;dt1=`date` &lt;BR /&gt;TODAY=`echo $dt1|cut -d" " -f3` &lt;BR /&gt;set -A DAYS Sat Sun Mon Tue Wed Thu Fri Sat &lt;BR /&gt;set -A MONTHS Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec &lt;BR /&gt;YESTERDAY=$((`date +%d` -1)) &lt;BR /&gt;MONTH=`date +%m` &lt;BR /&gt;YEAR=`date +%Y` &lt;BR /&gt;NDAY=`date +%u` &lt;BR /&gt;&lt;BR /&gt;tfile=$MONTH$TODAY$YEAR.lst &lt;BR /&gt;echo $tfile &lt;BR /&gt;WEEKDAY=${DAYS[`date +%u`]} &lt;BR /&gt;if [ $YESTERDAY -eq "0" ] &lt;BR /&gt;then &lt;BR /&gt;MONTH=$((MONTH-1)) &lt;BR /&gt;if [ $MONTH -eq "0" ] then &lt;BR /&gt;MONTH=12 &lt;BR /&gt;YEAR=$((YEAR-1)) fi &lt;BR /&gt;set `cal $MONTH $YEAR` &lt;BR /&gt;shift $(($# - 1)) &lt;BR /&gt;YESTERDAY=$1 &lt;BR /&gt;fi &lt;BR /&gt;TMONTH=${MONTHS[MONTH]} &lt;BR /&gt;yfile=$MONTH$YESTERDAY$YEAR.lst &lt;BR /&gt;echo "Y day File Name " $yfile &lt;BR /&gt;echo "T Day file Name " $tfile &lt;BR /&gt;ls -ltR /home/tmp &amp;gt;$tfile &lt;BR /&gt;&lt;BR /&gt;diff $tfile $yfile &amp;gt;result.chg &lt;BR /&gt;&lt;BR /&gt;Thanks for your help.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Henry</description>
    <pubDate>Wed, 12 Oct 2005 11:24:10 GMT</pubDate>
    <dc:creator>Henry  Richards</dc:creator>
    <dc:date>2005-10-12T11:24:10Z</dc:date>
    <item>
      <title>To pass comments on  a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647817#M102371</link>
      <description>Hi Guys&lt;BR /&gt;I have this script that runs everyday to Long list (ll in HPUX and ls -la in Solaris)all the files in all the directories.The Script when runs the nextday , captures the difference between previous day's longlist(ll) and currentday longlist (ll) using the diff command in HPUX "diff file1 file2 &amp;gt; file12"] and save it to new file titled "result".&lt;BR /&gt;&lt;BR /&gt;The Result file looks like this &lt;BR /&gt;&lt;BR /&gt;-rw-r--r--  1 root  sys  48  Sep 17 09:32 see &lt;BR /&gt;drwxr-xr-x  3 root  sys  96  Sep 17 08:58 tde5&lt;BR /&gt;drwxr-xr-x  2 root  sys  96  Sep 17 08:57 tse4&lt;BR /&gt;-rw-r--r--  1 root  sys  30  Sep 17 09:32 ree&lt;BR /&gt;&lt;BR /&gt;There are 9 fields in the "result" output file.&lt;BR /&gt;&lt;BR /&gt;Now I want to pass comments (like change in file owner or change in permission) for every file if there is any change in any of the fields of the file.&lt;BR /&gt;&lt;BR /&gt;Can you please suggest me a way to do it and that would fit to my below mentioned script.&lt;BR /&gt;The script is as follows:&lt;BR /&gt;&lt;BR /&gt;#! /usr/bin/sh &lt;BR /&gt;dt1=`date` &lt;BR /&gt;TODAY=`echo $dt1|cut -d" " -f3` &lt;BR /&gt;set -A DAYS Sat Sun Mon Tue Wed Thu Fri Sat &lt;BR /&gt;set -A MONTHS Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec &lt;BR /&gt;YESTERDAY=$((`date +%d` -1)) &lt;BR /&gt;MONTH=`date +%m` &lt;BR /&gt;YEAR=`date +%Y` &lt;BR /&gt;NDAY=`date +%u` &lt;BR /&gt;&lt;BR /&gt;tfile=$MONTH$TODAY$YEAR.lst &lt;BR /&gt;echo $tfile &lt;BR /&gt;WEEKDAY=${DAYS[`date +%u`]} &lt;BR /&gt;if [ $YESTERDAY -eq "0" ] &lt;BR /&gt;then &lt;BR /&gt;MONTH=$((MONTH-1)) &lt;BR /&gt;if [ $MONTH -eq "0" ] then &lt;BR /&gt;MONTH=12 &lt;BR /&gt;YEAR=$((YEAR-1)) fi &lt;BR /&gt;set `cal $MONTH $YEAR` &lt;BR /&gt;shift $(($# - 1)) &lt;BR /&gt;YESTERDAY=$1 &lt;BR /&gt;fi &lt;BR /&gt;TMONTH=${MONTHS[MONTH]} &lt;BR /&gt;yfile=$MONTH$YESTERDAY$YEAR.lst &lt;BR /&gt;echo "Y day File Name " $yfile &lt;BR /&gt;echo "T Day file Name " $tfile &lt;BR /&gt;ls -ltR /home/tmp &amp;gt;$tfile &lt;BR /&gt;&lt;BR /&gt;diff $tfile $yfile &amp;gt;result.chg &lt;BR /&gt;&lt;BR /&gt;Thanks for your help.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Henry</description>
      <pubDate>Wed, 12 Oct 2005 11:24:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647817#M102371</guid>
      <dc:creator>Henry  Richards</dc:creator>
      <dc:date>2005-10-12T11:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: To pass comments on  a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647818#M102372</link>
      <description>If I understand what you are trying to do here diff may not be your best option.  Diff will tell you which lines in the files that are different but it sounds to me like your goal is knowing which files in the listing are different&lt;BR /&gt;&lt;BR /&gt;I know it will take more scripting but it may be easier for you to create your list files so they have the relative path name as part of the file name&lt;BR /&gt;&lt;BR /&gt;Find . -exec ls -ld {} \; &amp;gt; listing.out&lt;BR /&gt;&lt;BR /&gt;Then write your own difference scanner using grep&lt;BR /&gt;&lt;BR /&gt;Cat listing.out | while read LINE&lt;BR /&gt;Do&lt;BR /&gt;FILE=$(echo $LINE | awk '{print $NF}')&lt;BR /&gt;OLD_LINE=$(grep $FILE oldlist.out)&lt;BR /&gt;If [ $LINE = $OLD_LINE]&lt;BR /&gt;Then&lt;BR /&gt;#the file has not changed&lt;BR /&gt;elseif [ $OLD_LINE = "" ]&lt;BR /&gt;then&lt;BR /&gt;# $FILE is new or was not in the old listing&lt;BR /&gt;else&lt;BR /&gt;#something about the file is different&lt;BR /&gt;#you can write something to parse it and find out exactly what&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;of course then you will have to run through the old list file and see if there are any files in it that are not in the new listing to check for deleted files.&lt;BR /&gt;&lt;BR /&gt;I think that is what I would do instead of trying to write something to interpret the diff out put.  Its up to you though&lt;BR /&gt;&lt;BR /&gt;H&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 12:40:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647818#M102372</guid>
      <dc:creator>Howard Marshall</dc:creator>
      <dc:date>2005-10-12T12:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: To pass comments on  a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647819#M102373</link>
      <description>A modification to Howard's script.&lt;BR /&gt;&lt;BR /&gt;Howard has you grep the oldlisting for the line, but that will not work if you have files with extensions of another files name (e.g. files fs and fs1 .. grep "fs" would find fs1) .... sooo I'll change that to awk.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;find . -exec ls -ld {} \; &amp;gt; listing.out&lt;BR /&gt;&lt;BR /&gt;Then write your own difference scanner using grep&lt;BR /&gt;&lt;BR /&gt;cat listing.out | while read LINE&lt;BR /&gt;do&lt;BR /&gt;FILE=$(echo $LINE | awk '{print $NF}')&lt;BR /&gt;touch myfile&lt;BR /&gt;rm myfile&lt;BR /&gt;echo "XYZZY" $FILE &amp;gt; myfile&lt;BR /&gt;cat oldlist.out&amp;gt;&amp;gt;myfile&lt;BR /&gt;OLD_LINE=$(awk '/XYZZY/{damatch=$2;next;}if(damatch==$NF){print $0}' myfile)&lt;BR /&gt;if [ $LINE = $OLD_LINE]&lt;BR /&gt;then&lt;BR /&gt;#the file has not changed&lt;BR /&gt;elseif [ $OLD_LINE = "" ]&lt;BR /&gt;then&lt;BR /&gt;# $FILE is new or was not in the old listing&lt;BR /&gt;else&lt;BR /&gt;#something about the file is different&lt;BR /&gt;#you can write something to parse it and #find out exactly what&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 13:30:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647819#M102373</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2005-10-12T13:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: To pass comments on  a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647820#M102374</link>
      <description>Thatâ  s true, and grabbing the last field won't work if you have symbolic links and I am sure there are other things wrong with my script as I didn't test it at all, just wrote it off the top of my head to point him in a possible new direction.&lt;BR /&gt;&lt;BR /&gt;I was going to leave the process of debugging and case testing to him, and then that wonderful thrill of getting the thing to finally work correctly.&lt;BR /&gt;&lt;BR /&gt;But thanks for pointing out that it won't run correctly as written.&lt;BR /&gt;&lt;BR /&gt;Henry, the script piece I wrote will not work as written.  It's just a suggested guideline for you.  If you want me to actually write the script for you please send a very large check toâ ¦..&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 16:21:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647820#M102374</guid>
      <dc:creator>Howard Marshall</dc:creator>
      <dc:date>2005-10-12T16:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: To pass comments on  a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647821#M102375</link>
      <description>&lt;BR /&gt;Henry, here is a starting point... in perl.&lt;BR /&gt;I just could not get past the ugly, hardcoded shell data manipulations.&lt;BR /&gt;It just does MODE and SIZE. You do the rest!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sample output:&lt;BR /&gt;&lt;BR /&gt;$ perl x.p&lt;BR /&gt;Y day File Name 10112005.lst&lt;BR /&gt;T Day file Name 10122005.lst&lt;BR /&gt;10112005.lst Size Change&lt;BR /&gt;ps.tmp DELETED&lt;BR /&gt;tux.p Mode Change&lt;BR /&gt;x.p Size Change&lt;BR /&gt;10122005.lst CREATED&lt;BR /&gt;&lt;BR /&gt;Script:&lt;BR /&gt;&lt;BR /&gt;$ cat x.p&lt;BR /&gt;#&lt;BR /&gt;# Format and print file names (turn into subroutine?)&lt;BR /&gt;#&lt;BR /&gt;@t=localtime(time()-86400);&lt;BR /&gt;$yfile = sprintf ("%d%02d%04d.lst",1+@t[4],@t[3],1900+@t[5]);&lt;BR /&gt;@t=localtime;&lt;BR /&gt;$tfile = sprintf ("%d%02d%04d.lst",1+@t[4],@t[3],1900+@t[5]);&lt;BR /&gt;print "Y day File Name $yfile\nT Day file Name $tfile\n";&lt;BR /&gt;#&lt;BR /&gt;# Get listing for today&lt;BR /&gt;# &lt;BR /&gt;system ("ls -ltr . &amp;gt; $tfile");&lt;BR /&gt;#&lt;BR /&gt;# loop through result from diff, remembering some attributes for each file name.&lt;BR /&gt;# Hopefully file names are unique.&lt;BR /&gt;# Stach attribute in "T" or "Y" array based on &amp;gt; pr &amp;lt;&lt;BR /&gt;#&lt;BR /&gt;foreach (`diff $tfile $yfile`) {&lt;BR /&gt; ($left_right, $mode, $links, $own, $group, $size, $d1, $d2, $t, $name) =split;&lt;BR /&gt; next unless $name;&lt;BR /&gt; $date = "$d1 $d2 $t";&lt;BR /&gt; if ($left_right eq '&amp;lt;') { $tmode{$name}=$mode, $tsize{$name}=$size };&lt;BR /&gt; if ($left_right eq '&amp;gt;') { $ymode{$name}=$mode, $ysize{$name}=$size };&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# Walk over yesterdays names, comparing attributes.&lt;BR /&gt;# Delete todays files attribute when processed.&lt;BR /&gt;#&lt;BR /&gt;foreach $name (sort keys %ymode) {&lt;BR /&gt; $line = $name;&lt;BR /&gt; $line .= " Mode Change" if ($tmode{$name} ne  $ymode{$name});&lt;BR /&gt; $line .= " Size Change" if ($tsize{$name} ne  $ysize{$name});&lt;BR /&gt; $line = "$name DELETED" unless defined $tmode{$name};&lt;BR /&gt; print "$line\n";&lt;BR /&gt; delete $tmode{$name};&lt;BR /&gt;}&lt;BR /&gt;#&lt;BR /&gt;# Any remaining todays file is newly created&lt;BR /&gt;#&lt;BR /&gt;foreach $name (sort keys %tmode) {&lt;BR /&gt; print "$name CREATED\n";&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 21:42:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647821#M102375</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-10-12T21:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: To pass comments on  a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647822#M102376</link>
      <description>You are executing diff command without option. I have tried to help and find as,&lt;BR /&gt;&lt;BR /&gt;# diff /test.log1 /test.log2 | grep -v '[0-9]*c[0-9]'&lt;BR /&gt;&amp;lt; -rw-rw-rw-   1 root       sys             33 Sep 21 00:08 ./tmpfile&lt;BR /&gt;---&lt;BR /&gt;&amp;gt; -rw-rw-rw-   1 muthu      sys             33 Sep 21 00:08 ./tmpfile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here, owner name is changed.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You can try as,&lt;BR /&gt;&lt;BR /&gt;cd &lt;DIRECTORY to="" change=""&gt;&lt;BR /&gt;&lt;BR /&gt;find . -type f &amp;gt; /tmp/log${today}.log&lt;BR /&gt;&lt;BR /&gt;diff /tmp/log${today}.log /tmp/log${yday}.log | grep -v '[0-9]*c[0-9]' &amp;gt; result.chg&lt;BR /&gt;&lt;BR /&gt;You can use my script there in,&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=961895" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=961895&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;It will not use more calculations.&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIRECTORY&gt;</description>
      <pubDate>Thu, 13 Oct 2005 02:53:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/to-pass-comments-on-a-script/m-p/3647822#M102376</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-10-13T02:53:46Z</dc:date>
    </item>
  </channel>
</rss>

