<?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: A Powerful shell script! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605261#M853641</link>
    <description>7 means only a portion of it helped. So, what's the portion this script is missing?. If you let me know I will try to put it in also.&lt;BR /&gt;You can copy &amp;amp; paste this script and can have it working.&lt;BR /&gt;&lt;BR /&gt;Response is very important so that we will know our mistakes.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
    <pubDate>Wed, 31 Oct 2001 23:36:11 GMT</pubDate>
    <dc:creator>Sridhar Bhaskarla</dc:creator>
    <dc:date>2001-10-31T23:36:11Z</dc:date>
    <item>
      <title>A Powerful shell script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605259#M853639</link>
      <description>&lt;BR /&gt;I have a file of the format below :&lt;BR /&gt;&lt;AUMENTATION level=""&gt;&lt;BR /&gt;      &lt;RULE&gt;&lt;BR /&gt;           &lt;CHECKSUM&gt; &lt;FILESIZE&gt; &lt;LOCATION&gt;&lt;BR /&gt;            ......&lt;BR /&gt;       &lt;RULE&gt; &lt;BR /&gt;         ......&lt;BR /&gt;and so on&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------------------------------&lt;BR /&gt;IBE augmentation level&lt;BR /&gt;    IBE rule&lt;BR /&gt;        1527753849 1163 Exports/CC&lt;BR /&gt;        1527753849 1163 Exports/Global_wrapper&lt;BR /&gt;        1527753849 1163 Exports/yacc&lt;BR /&gt;        4294967295 0 FILELIST.IBE&lt;BR /&gt;        3618088840 5846 README.FIRST&lt;BR /&gt;ABE.IC augmentation level&lt;BR /&gt;    clear rule&lt;BR /&gt;        1743432609 16384 usr/bin/clear&lt;BR /&gt;    dev rule&lt;BR /&gt;        68954040 218620 dev/core&lt;BR /&gt;    dld rule&lt;BR /&gt;        1105456478 102400 usr/lib/dld.sl&lt;BR /&gt;&lt;BR /&gt;-----------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Each level corresponds to a source directory&lt;BR /&gt;eg.IBE corresponds to /ha/be/sa_ems/IBE/&lt;BR /&gt;and the locations correspond to files under them.&lt;BR /&gt;eg if there is Exports/CC, it means&lt;BR /&gt;there is a file /ha/be/sa_ems/IBE/Exports/CC&lt;BR /&gt;and it has corresponding checksum,size as indicated&lt;BR /&gt;&lt;BR /&gt;What I need to do:&lt;BR /&gt;copy the files to a particular directory from all these various locations &lt;BR /&gt;&lt;BR /&gt;eg.Let's say the target root dir is /BE/&lt;BR /&gt;the for the line &lt;BR /&gt;   Exports/CC&lt;BR /&gt;&lt;BR /&gt;I will have to&lt;BR /&gt;1. find the level and get the base source dir&lt;BR /&gt;In this case it is IBE which corresponds to /ha/be/sa_ems/IBE/&lt;BR /&gt;&lt;BR /&gt;2.create any sub-dirs under /BE if required.&lt;BR /&gt; In this case it is Exports&lt;BR /&gt;So, I will have to create Exports under /BE/&lt;BR /&gt;&lt;BR /&gt;3.check for  the file and verify whether the checksum and sixe are correct&lt;BR /&gt;&lt;BR /&gt;4.If step 3 succeeds,copy it to the target dir&lt;BR /&gt;&lt;BR /&gt;In this case it is CC&lt;BR /&gt;so,I will have to copy CC to /BE/Exports/CC&lt;BR /&gt;&lt;BR /&gt;5.Retain the permissions,owner,group of the file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It is really big process,and there are hundreds of such lines and there are many such files.&lt;BR /&gt;&lt;BR /&gt;Can anyone provide some script or any ideas/suggestions&lt;BR /&gt;/or any information on these.&lt;BR /&gt;It would be highly appreciated and highly Rewarded:)&lt;BR /&gt;&lt;BR /&gt;Waiting for many responses:)&lt;BR /&gt;&lt;BR /&gt;-Jayes&lt;/RULE&gt;&lt;/LOCATION&gt;&lt;/FILESIZE&gt;&lt;/CHECKSUM&gt;&lt;/RULE&gt;&lt;/AUMENTATION&gt;</description>
      <pubDate>Wed, 31 Oct 2001 21:50:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605259#M853639</guid>
      <dc:creator>Jayesh shah</dc:creator>
      <dc:date>2001-10-31T21:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: A Powerful shell script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605260#M853640</link>
      <description>Hi Jayesh,&lt;BR /&gt;&lt;BR /&gt;Good food. Try this.&lt;BR /&gt;&lt;BR /&gt;//start&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh                                                          &lt;BR /&gt;                                                                        &lt;BR /&gt;#change these to the applicable                                         &lt;BR /&gt;                                                                        &lt;BR /&gt;INFILE=/full_path_to_your_formatted_file                                &lt;BR /&gt;TMP=/tmp/input$$                                                        &lt;BR /&gt;PARENT=/ha/be/sa_ems                                                    &lt;BR /&gt;TARGET=/                                                                &lt;BR /&gt;                                                                        &lt;BR /&gt;#Change if you want                                                     &lt;BR /&gt;                                                                        &lt;BR /&gt;LOG=/tmp/output.log                                                     &lt;BR /&gt;ERRLOG=/tmp/err.log                                                     &lt;BR /&gt;TMPTAR=/tmp/tmp.tar                                                     &lt;BR /&gt;                                                                        &lt;BR /&gt;for SRC in `grep "augmentation level" $INFILE |awk '{print $1}'`        &lt;BR /&gt;do                                                                      &lt;BR /&gt;cd ${PARENT}/${SRC}                                                     &lt;BR /&gt;mkdir ${TARGET}/${SRC}                                                  &lt;BR /&gt;sed -n '/'$SRC' augmentation level/,/augmentation level/p' $INFILE \    &lt;BR /&gt;|sed  '/augmentation level/d' |sed  '/rule/d'  &amp;gt; $TMP                   &lt;BR /&gt;                                                                        &lt;BR /&gt;cat $TMP|while read LINE                                                                                                                   &lt;BR /&gt;do                                                                 &lt;BR /&gt;FILE=`echo $LINE|awk '{print $3}'`                                 &lt;BR /&gt;if [ -f $FILE ]                                                    &lt;BR /&gt;then                                                               &lt;BR /&gt;RESULT=`cksum $FILE`                                               &lt;BR /&gt;if [ "$RESULT" = "$LINE" ]                                         &lt;BR /&gt;then                                                               &lt;BR /&gt;tar cf $TMPTAR $FILE                                               &lt;BR /&gt;cd ${TARGET}/${SRC}                                                &lt;BR /&gt;tar xf $TMPTAR                                                     &lt;BR /&gt;echo "$SRC: $LINE has been successful" &amp;gt;&amp;gt; $LOG                     &lt;BR /&gt;cd ${PARENT}/${SRC}                                                &lt;BR /&gt;else                                                               &lt;BR /&gt;echo "$SRC: $LINE has checksum problems" &amp;gt;&amp;gt; $ERRLOG                &lt;BR /&gt;fi                                                                 &lt;BR /&gt;else                                                               &lt;BR /&gt;echo "$SRC: $LINE doesnot exist" &amp;gt;&amp;gt; $ERRLOG                        &lt;BR /&gt;fi                                                                 &lt;BR /&gt;                                                                   done                        &lt;BR /&gt;                            &lt;BR /&gt;                            &lt;BR /&gt;done                        &lt;BR /&gt;                            &lt;BR /&gt;                            &lt;BR /&gt;rm $TMP $TMPTAR             &lt;BR /&gt;&lt;BR /&gt;//END&lt;BR /&gt;&lt;BR /&gt;See if it works... I am just tarring it up and untarring so that it will take care of permissions/ownership and subdirectories etc.,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 31 Oct 2001 23:04:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605260#M853640</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-10-31T23:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: A Powerful shell script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605261#M853641</link>
      <description>7 means only a portion of it helped. So, what's the portion this script is missing?. If you let me know I will try to put it in also.&lt;BR /&gt;You can copy &amp;amp; paste this script and can have it working.&lt;BR /&gt;&lt;BR /&gt;Response is very important so that we will know our mistakes.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 31 Oct 2001 23:36:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605261#M853641</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-10-31T23:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: A Powerful shell script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605262#M853642</link>
      <description>Actually,The script  provided by Sridhar does almost everything that I require.&lt;BR /&gt;&lt;BR /&gt;There is only one small problem (rather I should have not taken note of it while assigning points)&lt;BR /&gt;&lt;BR /&gt;mkdir should have been mkdir -p.&lt;BR /&gt;&lt;BR /&gt;The other point is : the PARENT  is dependent on the augmentation level.Well,My mistake,I did not give full info.&lt;BR /&gt;&lt;BR /&gt;The last line may or may not be augmentation level line.&lt;BR /&gt; &lt;BR /&gt;Sridhar,Your help is really appreciated.&lt;BR /&gt;-Jayesh&lt;BR /&gt;</description>
      <pubDate>Wed, 31 Oct 2001 23:53:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605262#M853642</guid>
      <dc:creator>Jayesh shah</dc:creator>
      <dc:date>2001-10-31T23:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: A Powerful shell script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605263#M853643</link>
      <description>Jayesh,&lt;BR /&gt;&lt;BR /&gt;You are right.. It should be mkdir -p.&lt;BR /&gt;&lt;BR /&gt;The second thing is that the some portion of your PARENT DIRECTORY is independent of your augmentation level. So, we can just assign it to $PARENT as it doesnt' change.&lt;BR /&gt;&lt;BR /&gt;If you check the other line, I am going into the dependent directory by doing a&lt;BR /&gt;&lt;BR /&gt;cd ${PARENT}/${SRC} where SRC is derived based on each "augmentation level" header.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Nov 2001 04:07:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605263#M853643</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-11-01T04:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: A Powerful shell script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605264#M853644</link>
      <description>Hi Jayesh,&lt;BR /&gt;&lt;BR /&gt;Here's how to do it within awk.  Pls note, I've put echo statements in to show what it *would* do.  Remove the "echo" to actually run the script.&lt;BR /&gt;&lt;BR /&gt;===========================================&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;INDIR=/ha/be/sa_ems&lt;BR /&gt;OUTDIR=/BE&lt;BR /&gt;INPUT=your_input_file_name&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;/augmentation level/{SUBDIR=$1;next}&lt;BR /&gt;NF==3{&lt;BR /&gt; FNAME=$3;$3=INDIR"/"SUBDIR"/"$3;line=$0;FILE=$3;$0="";print FILE&lt;BR /&gt; "cksum "FILE " 2&amp;gt;/dev/null"|getline;close "cksum "FILE "2&amp;gt;/dev/null"&lt;BR /&gt;print line&lt;BR /&gt; if (line == $0)&lt;BR /&gt; {&lt;BR /&gt;  "dirname "FNAME|getline;close "dirname "FNAME&lt;BR /&gt;  system ("echo mkdir -p "OUTDIR"/"$0)&lt;BR /&gt;  system("echo cp -p "INDIR"/"SUBDIR"/"FNAME" "OUTDIR"/"FNAME)&lt;BR /&gt; }&lt;BR /&gt;}' INDIR=$INDIR OUTDIR=$OUTDIR $INPUT&lt;BR /&gt;&lt;BR /&gt;============================================&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Thu, 01 Nov 2001 10:31:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605264#M853644</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-11-01T10:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: A Powerful shell script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605265#M853645</link>
      <description>The while loop breaks before reading the complete file ?&lt;BR /&gt;&lt;BR /&gt;What could be the reason?&lt;BR /&gt;-----------------------------&lt;BR /&gt;                                     cat $TMP|while read LINE &lt;BR /&gt;                                     do &lt;BR /&gt;                                     FILE=`echo $LINE|awk '{print $3}'` &lt;BR /&gt;                                     if [ -f $FILE ] &lt;BR /&gt;                                     then &lt;BR /&gt;                                     RESULT=`cksum $FILE` &lt;BR /&gt;                                     if [ "$RESULT" = "$LINE" ] &lt;BR /&gt;                                     then &lt;BR /&gt;&lt;BR /&gt;.....&lt;BR /&gt;-----------------------------</description>
      <pubDate>Sat, 03 Nov 2001 09:10:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-powerful-shell-script/m-p/2605265#M853645</guid>
      <dc:creator>Jayesh shah</dc:creator>
      <dc:date>2001-11-03T09:10:19Z</dc:date>
    </item>
  </channel>
</rss>

