<?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 shell problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606872#M853652</link>
    <description>You are probably right about the buffer. run this again, but this time do a "set -x" so that you can watch it. if it is a buffer issue, it'll never do the read LINE. This also look like a great opportunity to learn perl.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
    <pubDate>Sat, 03 Nov 2001 12:49:51 GMT</pubDate>
    <dc:creator>harry d brown jr</dc:creator>
    <dc:date>2001-11-03T12:49:51Z</dc:date>
    <item>
      <title>A shell problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606870#M853650</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;I have a simple shell script of the form: &lt;BR /&gt;&lt;BR /&gt;for var in list &lt;BR /&gt;do &lt;BR /&gt; --- write something into a file say TMP ----- &lt;BR /&gt;&lt;BR /&gt; --- read line by line and &lt;BR /&gt;          ------ for each line &lt;BR /&gt;                          do some actions. &lt;BR /&gt;&lt;BR /&gt;The problem is the cotrol breaks from the inner loop even w/o completely reading the file . &lt;BR /&gt;&lt;BR /&gt;It looks to be a problem with the shell buffer or something else? &lt;BR /&gt;  &lt;BR /&gt;&lt;BR /&gt;The original script  is below (MKDIR and CREATELINK are small shell script for creating dirs and links in clearcase environment) &lt;BR /&gt;I have highlighted the problem part in blue. &lt;BR /&gt;Can any one pinpoint the actaul cause for the problem? &lt;BR /&gt;  &lt;BR /&gt;&lt;BR /&gt;================================================================================================== &lt;BR /&gt;&lt;BR /&gt;set -xv &lt;BR /&gt;PRODUCT=$1 &lt;BR /&gt;FLAVOR=$3 &lt;BR /&gt;RELEASE=$2 &lt;BR /&gt;&lt;BR /&gt;BE_ROOT=/ha/be_sam &lt;BR /&gt;INFILE=$BE_ROOT/manifest.$PRODUCT.$FLAVOR &lt;BR /&gt;MAPPING=$HOME/MAPPING &lt;BR /&gt;TMP=$HOME/input$$ &lt;BR /&gt;TARGET=$BE_ROOT/"$RELEASE"_$FLAVOR/ &lt;BR /&gt;&lt;BR /&gt;CREATEABELOG=$HOME/log/CREATEABELOG$$ &lt;BR /&gt;CREATEABEERR=$HOME/log/CREATEABEERR$$ &lt;BR /&gt;MKDIR=$HOME/bin/MKDIR &lt;BR /&gt;CREATELINK=$HOME/bin/CREATELINK &lt;BR /&gt;&lt;BR /&gt;if [ ! -f $CREATEABELOG ] &lt;BR /&gt;then &lt;BR /&gt;touch $CREATEABELOG &lt;BR /&gt;else &lt;BR /&gt;rm $CREATEABELOG &lt;BR /&gt;touch $CREATEABELOG &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;if [ ! -f $CREATEABEERR ] &lt;BR /&gt;then &lt;BR /&gt;touch $CREATEABEERR &lt;BR /&gt;else &lt;BR /&gt;rm $CREATEABEERR &lt;BR /&gt;touch $CREATEABEERR &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;if [ ! -f $CREATEABELOG -o ! -f $CREATEABEERR  ] &lt;BR /&gt;then &lt;BR /&gt;echo "$CREATEABELOG OR $CREATEABEERR COULD NOT BE CREATED" &lt;BR /&gt;exit 1 &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;if [ ! -f $MAPPING ] &lt;BR /&gt;then &lt;BR /&gt;echo "$MAPPING DOES NOT EXIST" &lt;BR /&gt;exit 1 &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;if [ ! -r $INFILE ] &lt;BR /&gt;then &lt;BR /&gt;echo "$INFILE DOES NOT EXIST OR IS NOT READABLE" &lt;BR /&gt;exit 1 &lt;BR /&gt;fi &lt;BR /&gt;  &lt;BR /&gt;&lt;BR /&gt;for SRC in `grep "augmentation level" $INFILE |awk '{print $1}'` &lt;BR /&gt;do &lt;BR /&gt;sed -n '/'$SRC' augmentation level/,/augmentation level/p' $INFILE | sed '/augmentation level/d' |sed '/rule/d'  &amp;gt;$TMP &lt;BR /&gt;&lt;BR /&gt;ROOTSRCDIR=`grep $SRC $MAPPING | cut -f2` &lt;BR /&gt;&lt;BR /&gt;echo "==============================" &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;DIR=`dirname $FILE` &lt;BR /&gt;echo "LINE ....$LINE" &lt;BR /&gt;if [ ! -d $TARGET/$DIR ] &lt;BR /&gt;then &lt;BR /&gt;$MKDIR $TARGET/$DIR $CREATEABELOG $CREATEABEERR &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;if [ -f $ROOTSRCDIR/$FILE ] &lt;BR /&gt;then &lt;BR /&gt;   RESULT=`cksum $ROOTSRCDIR/$FILE | awk '{ print $1 $2 }'` &lt;BR /&gt;   LINE12=`echo $LINE | awk '{ print $1 $2 }'` &lt;BR /&gt;   if [ "$RESULT" = "$LINE12" ] &lt;BR /&gt;   then &lt;BR /&gt;      $CREATELINK $ROOTSRCDIR/$FILE $TARGET/$FILE $CREATEABELOG $CREATEABEERR &lt;BR /&gt;   else &lt;BR /&gt;      echo "$ROOTSRCDIR/$FILE has checksum problems" &amp;gt;&amp;gt; $CREATEABEERR &lt;BR /&gt;   fi &lt;BR /&gt;else &lt;BR /&gt;   echo "$ROOTSRCDIR/$FILE does not exist" &amp;gt;&amp;gt; $CREATEABEERR &lt;BR /&gt;fi &lt;BR /&gt;  &lt;BR /&gt;&lt;BR /&gt;done &lt;BR /&gt;  &lt;BR /&gt;  &lt;BR /&gt;  &lt;BR /&gt;&lt;BR /&gt;done &lt;BR /&gt;======================================================================================= &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 03 Nov 2001 09:25:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606870#M853650</guid>
      <dc:creator>Jayesh shah</dc:creator>
      <dc:date>2001-11-03T09:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: A shell problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606871#M853651</link>
      <description>The problem part is &lt;BR /&gt;cat $TMP | while read LINE &lt;BR /&gt;&lt;BR /&gt;....&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Jayesh</description>
      <pubDate>Sat, 03 Nov 2001 09:26:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606871#M853651</guid>
      <dc:creator>Jayesh shah</dc:creator>
      <dc:date>2001-11-03T09:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: A shell problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606872#M853652</link>
      <description>You are probably right about the buffer. run this again, but this time do a "set -x" so that you can watch it. if it is a buffer issue, it'll never do the read LINE. This also look like a great opportunity to learn perl.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sat, 03 Nov 2001 12:49:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606872#M853652</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2001-11-03T12:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: A shell problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606873#M853653</link>
      <description>I had tried set -x.&lt;BR /&gt;It does read LINE,&lt;BR /&gt;but i do not know it breaks all of a sudden to the outer loop.&lt;BR /&gt;I do not understand the reason.Well,Is it easy to write the same in perl?</description>
      <pubDate>Sat, 03 Nov 2001 12:56:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606873#M853653</guid>
      <dc:creator>Jayesh shah</dc:creator>
      <dc:date>2001-11-03T12:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: A shell problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606874#M853654</link>
      <description>Hi Jayesh:&lt;BR /&gt;&lt;BR /&gt;I think the essential problem is that your outer 'do' loop is writing to the TMP file, while the inner loop is attempting to read the same file.  I suggest that you rearrange your code into two indepenedent passes -- the first to write to the file; the second to read the updated information.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 03 Nov 2001 14:45:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606874#M853654</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-11-03T14:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: A shell problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606875#M853655</link>
      <description>This is close, but because I donw't have your system to test on, it's not exact. &lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl???? you need to put the path to perl here&lt;BR /&gt;&lt;BR /&gt;$PRODUCT=$1;&lt;BR /&gt;$FLAVOR=$3;&lt;BR /&gt;$RELEASE=$2;&lt;BR /&gt;&lt;BR /&gt;$BE_ROOT=/ha/be_sam;&lt;BR /&gt;$INFILE=$BE_ROOT/manifest.$PRODUCT.$FLAVOR;&lt;BR /&gt;$MAPPING=$HOME/MAPPING;&lt;BR /&gt;&lt;BR /&gt;$TARGET=$BE_ROOT/"$RELEASE"_$"FLAVOR/";&lt;BR /&gt;&lt;BR /&gt;$CREATEABELOG=$HOME/log/CREATEABELOG$$;&lt;BR /&gt;$CREATEABEERR=$HOME/log/CREATEABEERR$$;&lt;BR /&gt;$MKDIR=$HOME/bin/MKDIR;&lt;BR /&gt;$CREATELINK=$HOME/bin/CREATELINK;&lt;BR /&gt;&lt;BR /&gt;eval `cat /dev/null &amp;gt;$CREATEABELOG` or die "Could not null $CREATEABELOG";&lt;BR /&gt;open (ABELOG,"&amp;gt;&amp;gt;$CREATEABELOG") || die "Could not open $CREATEABELOG for appending";&lt;BR /&gt;eval `cat /dev/null &amp;gt;$CREATEABEERR` or die "Could not null $CREATEABEERR";&lt;BR /&gt;open (ABEERR,"&amp;gt;&amp;gt;$CREATEABEERR") || die "Could not open $CREATEABEERR for appending";&lt;BR /&gt;&lt;BR /&gt;open (FILEHANDLE, $MAPPING ) || die "MAPPING DOES NOT EXIST";&lt;BR /&gt;open (FILEHANDLE, $INFILE ) || die "INFILE DOES NOT EXIST OR IS NOT READABLE";&lt;BR /&gt;open (SRClist, `grep "augmentation level" $INFILE |awk '{print $1}'|` ) || die "No data to process";&lt;BR /&gt;&lt;BR /&gt;while ($src=&lt;SRCLIST&gt;) {&lt;BR /&gt;   chop($SRC);&lt;BR /&gt;&lt;BR /&gt;   open (TMP, `sed -n '/'$SRC' augmentation level/,/augmentation level/p' $INFILE | sed '/augmentation level/d' |sed '/rule/d'|` ) || die "No data to process";&lt;BR /&gt;&lt;BR /&gt;   $ROOTSRCDIR=`grep $SRC $MAPPING | cut -f2`;&lt;BR /&gt;&lt;BR /&gt;   print "==============================\n";&lt;BR /&gt;&lt;BR /&gt;   while ($LINE = &lt;TMP&gt;) {&lt;BR /&gt;      chop($LINE);&lt;BR /&gt; &lt;BR /&gt;      $FILE=`echo $LINE|awk '{ print $3 }'`;&lt;BR /&gt;      $DIR=`dirname $FILE`;&lt;BR /&gt;      print "LINE ....$LINE\n";&lt;BR /&gt;&lt;BR /&gt;      if (! -d "$TARGET/$DIR" ) {&lt;BR /&gt;          `$MKDIR $TARGET/$DIR $CREATEABELOG $CREATEABEERR`;&lt;BR /&gt;      }&lt;BR /&gt;&lt;BR /&gt;      if ( -f "$ROOTSRCDIR/$FILE" ) {&lt;BR /&gt;          $RESULT=`cksum $ROOTSRCDIR/$FILE | awk '{ print $1 $2 }'`;&lt;BR /&gt;          $LINE12=`echo $LINE | awk '{ print $1 $2 }'`;&lt;BR /&gt;          if ( $RESULT eq $LINE12 ) {&lt;BR /&gt;              eval `$CREATELINK $ROOTSRCDIR/$FILE $TARGET/$FILE $CREATEABELOG $CREATEABEERR` or die "Could not create link";&lt;BR /&gt;          } else {&lt;BR /&gt;              print ABEERR "$ROOTSRCDIR/$FILE has checksum problems\n";&lt;BR /&gt;          }&lt;BR /&gt;     } else {&lt;BR /&gt;          print ABEERR "$ROOTSRCDIR/$FILE does not exist\n";&lt;BR /&gt;     }&lt;BR /&gt;}&lt;BR /&gt;}&lt;/TMP&gt;&lt;/SRCLIST&gt;</description>
      <pubDate>Sat, 03 Nov 2001 14:53:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606875#M853655</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2001-11-03T14:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: A shell problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606876#M853656</link>
      <description>I did rearrange the code into two indepenedent passes -- the first to write to the file; the second to read the                                 updated information.&lt;BR /&gt;&lt;BR /&gt;But the problem remains.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 03 Nov 2001 15:50:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606876#M853656</guid>
      <dc:creator>Jayesh shah</dc:creator>
      <dc:date>2001-11-03T15:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: A shell problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606877#M853657</link>
      <description>The perl script gives a lot of syntax like bare?  something.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 03 Nov 2001 15:51:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606877#M853657</guid>
      <dc:creator>Jayesh shah</dc:creator>
      <dc:date>2001-11-03T15:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: A shell problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606878#M853658</link>
      <description>I'll connect into one of my servers and do a little testing. Hopefully I'll have an answer  today, or at least by monday morn.&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sat, 03 Nov 2001 15:57:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606878#M853658</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2001-11-03T15:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: A shell problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606879#M853659</link>
      <description>Here, I modified the syntax - damn typos....&lt;BR /&gt;&lt;BR /&gt;its in the attachment&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sat, 03 Nov 2001 17:05:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-shell-problem/m-p/2606879#M853659</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2001-11-03T17:05:36Z</dc:date>
    </item>
  </channel>
</rss>

