Re: [foxboro] save_all script | Bugs and Solutions

Hi Ignacio,

Thanks for the bug report (and included workaround), this is a great
help to improve the tool.
We will do our best to take good care of these.

Met vriendelijke groeten / Kindest regards,

Ron Deen
Technical Sales consultant
Invensys Systems N.V.
T: +31 (0)35 54 84 233
F: +31 (0)35 54 84 175
M: +31 (0)653 963 616
E: Ron.Deen@xxxxxxxxxxxxxxxx
www.ips.invensys.com
FPAL Supplier Number: 10049469
 

 

-----Original Message-----
From: foxboro-bounce@xxxxxxxxxxxxx [mailto:foxboro-bounce@xxxxxxxxxxxxx]
On Behalf Of QUEIROLO OLIVERA, IGNACIO ESTEBAN
Sent: woensdag 10 december 2008 11:51
To: foxboro@xxxxxxxxxxxxx
Subject: [foxboro] save_all script | Bugs and Solutions

Content-Type: text/plain;
        charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello all,

=20

I am one of a user of the save_all.sh script to do automatic save alls
on the system. Some time ago I found two bugs. Here is a summary with
the solution adopted.

=20

First bug:

=20

If you have a compound with the word "STA" at the end of its name then
this is for you, otherwise you can skip to the second bug.

=20

The bug was in the save all of one of our CP where the name of the
backup file was like [date].Z (e.g.: 24Dec0331.Z) instead of the name
with the letterbug and the date.

=20

I checked the log file and I had something like (the CP letterbug is
09CL07):

=20

#####################################################

 Save_all starting for: 09CL07 hosted by 09AW01

-----------------------------------------------------

Found a previously stored save_all for this station.

Making back-up first

...backing-up 09CL07

Back-up is: /opt/SAVEALLS/backup/24Dec0331

24Dec0331

24Dec0331

24Dec0331_09CL07.tar.Z

Starting upload/checkpoint....

  Sun Dec 31 03:11:52 GMT 2006

  Upload and checkpoint 09CL07

DONE     1 OPEN 09CL07!: Sun Dec 31 03:11:52 2006

DONE     2 UPLOAD 09CL07!: Sun Dec 31 03:30:07 2006

DONE     3 CHECKPOINT 09CL07!: Sun Dec 31 03:32:38 2006

DONE     4 CLOSE 09CL07!: Sun Dec 31 03:32:38 2006

DONE     5 EXIT 09CL07!: Sun Dec 31 03:32:38 2006

Upload & checkpoint ready

Save_all for 09CL07 started

Searching for sequence include files...

Save-all for 09CL07 successfully completed.

#####################################################

=20

Then I was inspecting the save_all.sh script to see what the program
does in the part related to backups and I have discovered something that
could be the problem for me. The part is (started at line 794):

=20

if [ -d $SA_DIR/$CP/*STA ] && [ $LOCK =3D "no" ]

      then

             echo "Found a previously stored save_all for this station."
| tee -a $LOG

             echo "Making back-up first" >> $LOG

             echo "Making back-up first\r\c"=20

             NAME=3D`ls -ld $SA_DIR/$CP/*STA"" | awk '{print $7 $6 $8}'
=
|
sed s/\://`

             cd $SA_DIR

             echo "...backing-up $CP" >> $LOG

             echo "...backing-up $CP \r\c"=20

             tar cf $BU_DIR/$NAME"_"$CP.tar $SA_DIR/$CP > /dev/null 2>&1

         if [ -f $SA_DIR/include/$CP.tar ]

         then

           tar rf $BU_DIR/$NAME"_"$CP.tar $SA_DIR/include/$CP.tar
>/dev/null

           rm $SA_DIR/include/$CP.tar

         fi

             compress -f $BU_DIR/$NAME"_"$CP.tar >/dev/null

             echo "Back-up is: ""$BU_DIR""/""$NAME""_""$CP.tar.Z" | tee
-a $LOG

         # determine level of backups until now

         LVL=3D`ls -l $BU_DIR/*"$CP"*|wc -l` 2>/dev/null

         DEL=3D`echo "$LVL - $ARCHNR" |bc`

         if [ $DEL -gt 0 ]

         then

            if [ $DEL -gt 1 ]=20

            then

              echo

              echo ""$DEL" archived save_all(s) will be deleted"

              echo "Press CTRL-C to abort"

              TIMELEFT=3D$TIMEOUT

              while [ $TIMELEFT -gt -1 ]=20

              do

                echo "Continuing in $TIMELEFT  \r\c";sleep 1;

                TIMELEFT=3D`echo $TIMELEFT - 1|bc`=20

              done

              echo "Removing surplus archives" | tee -a $LOG

            fi

            for DELFILE in `ls -lt $BU_DIR/*"$CP"*|tail -$DEL|awk
'{print $9}'`

            do

              rm $DELFILE

            done

         fi

=20

This CP has three compounds whose names are:

=20

REFORMERSTA

XILENOSTA

N701_702STA

=20

These compounds are related with DMCplus controller's status and that's
why they are named with the letters "STA" at the end of its name (that
was our mistake). In the save_all.sh script there is a variable (called
"NAME") which is used to take the date of the last save all and form the
name of the tar file with the backup. When the script runs, the variable
NAME find three compounds with "STA" at the end and produced an error
that causes the name of the file be [date].Z.

=20

The solution adopted was modified the script to filter this compounds
and in that way this variable "NAME" will be set with the value
belonging to the 09CL07_STA compound. I have added a new variable
(UCCPLB, UpperCase CP LetterBug) to take the name of the compound in
uppercase (this because the library volume names are in lowercase but
the compound inside is in uppercase). Then I form the name of the file
with this variable plus the CP letterbug. The following lines are the
lines with the changes I made (started at line 794):

=20

if [ -d $SA_DIR/$CP/*STA ] && [ $LOCK =3D "no" ]

      then

             echo "Found a previously stored save_all for this station."
| tee -a $LOG

             echo "Making back-up first" >> $LOG

             echo "Making back-up first\r\c"=20

             #NAME=3D`ls -ld $SA_DIR/$CP/*STA"" | awk '{print $7 $6 $8}'
=
|
sed s/\://`

             UCCPLB=3D`echo $CP | tr '[a-z]' '[A-Z]'`

             NAME=3D`ls -ld $SA_DIR/$CP/"$UCCPLB"_*STA | awk '{print $7
=
$6
$8}' | sed s/\://`

             cd $SA_DIR

             echo "...backing-up $CP" >> $LOG

             echo "...backing-up $CP \r\c"=20

             tar cf $BU_DIR/$NAME"_"$CP.tar $SA_DIR/$CP > /dev/null 2>&1

         if [ -f $SA_DIR/include/$CP.tar ]

         then

           tar rf $BU_DIR/$NAME"_"$CP.tar $SA_DIR/include/$CP.tar
>/dev/null

           rm $SA_DIR/include/$CP.tar

         fi

             compress -f $BU_DIR/$NAME"_"$CP.tar >/dev/null

             echo "Back-up is: ""$BU_DIR""/""$NAME""_""$CP.tar.Z" | tee
-a $LOG

         # determine level of backups until now

         LVL=3D`ls -l $BU_DIR/*"$CP"*|wc -l` 2>/dev/null

         DEL=3D`echo "$LVL - $ARCHNR" |bc`

         if [ $DEL -gt 0 ]

         then

            if [ $DEL -gt 1 ]=20

            then

              echo

              echo ""$DEL" archived save_all(s) will be deleted"

              echo "Press CTRL-C to abort"

              TIMELEFT=3D$TIMEOUT

              while [ $TIMELEFT -gt -1 ]=20

              do

                echo "Continuing in $TIMELEFT  \r\c";sleep 1;

                TIMELEFT=3D`echo $TIMELEFT - 1|bc`=20

              done

              echo "Removing surplus archives" | tee -a $LOG

            fi

            for DELFILE in `ls -lt $BU_DIR/*"$CP"*|tail -$DEL|awk
'{print $9}'`

            do

              rm $DELFILE

            done

         fi

=20

Second bug:

=20

The second bug was related with a variable whose name has a mistake. The
variable is CUR_DIR and the correct one (I think) is CURDIR. The
following lines show this (started at line 600):

=20

########################################################################
########

# printing a list of all the stations / hosts to be processed

########################################################################
########

echo;echo "Stations selected for save_all:" | tee -a $LOG

echo "Station      Host name" | tee -a $LOG

for CP in `cat $CPFILE`

do

   HOST=3D`awk '{if ($1=3D=3Dcp) {print $2} }' cp=3D$CP < $SLDB`

   if [ $HOST_SLCT !=3D "yes" ]=20

   then=20

      echo "$CP       $HOST" | tee -a $LOG $CURDIR/"$PF"cpap

   else=20

      echo "$CP       $HOST" >> $CURDIR/"$PF"cpap

   fi

done

# When there was a selection of hosts the HOST_SLCT variable is yes

if [ $HOST_SLCT =3D "yes" ]

then

   rm "$CURDIR"/"$PF"scratch > /dev/null 2>&1

   for AP in `cat "$HOSTFILE"`

   do

      cat "$CURDIR"/"$PF"cpap | grep $AP >> "$CURDIR"/"$PF"scratch

   done

   # let's see what we have

   cat "$CURDIR"/"$PF"scratch | tee -a $LOG

   cat "$CURDIR"/"$PF"scratch | awk ' {print $1}' > $CUR_DIR/"$PF"cplns

   CPFILE=3D$CUR_DIR/"$PF"cplns

fi

=20

The solution adopted was changed CUR_DIR with CURDIR.

=20

I hope that this will be useful for you.

=20

Regards,

=20

=20

=20

Ignacio Queirolo
Control Avanzado
Complejo Industrial Ensenada
tel.: 54 221 429-8400 ext. 26481=20

=20




 
 
_______________________________________________________________________
This mailing list is neither sponsored nor endorsed by Invensys Process
Systems (formerly The Foxboro Company). Use the info you obtain here at
your own risks. Read http://www.thecassandraproject.org/disclaimer.html
 
foxboro mailing list:             http://www.freelists.org/list/foxboro
to subscribe:         mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
to unsubscribe:      mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
 


* Confidentiality Notice:
This e-mail and any associated files are intended solely for the individual or 
entity to whom they are addressed. Please do not copy it or use it for any 
purposes, or disclose its contents to any other person. Further, this e-mail 
and any associated files may be confidential and further may be legally 
privileged. This email is from the Invensys Process Systems business unit of 
Invensys plc which is a company registered in England and Wales with its 
registered office at Portland House, Bressenden Place, London, SW1E 5BF 
(Registered number 166023).  For a list of European legal entities within the 
Invensys Process Systems business group, please click here 
http://www.invensys.com/legal/default.asp?top_nav_id=77&nav_id=80&prev_id=77.

If you have received this e-mail in error, you are on notice of its status. 
Please notify us immediately by reply e-mail and then delete this message from 
your system. Thank you for your co-operation. You may contact our Helpdesk on 
+44 (0)20 7821 3859 / 2105 or email inet.hqhelpdesk@xxxxxxxxxxxxx This e-mail 
and any attachments thereto may be subject to the terms of any agreements 
between Invensys (and/or its subsidiaries and affiliates) and the recipient 
(and/or its subsidiaries and affiliates).


 
 
_______________________________________________________________________
This mailing list is neither sponsored nor endorsed by Invensys Process
Systems (formerly The Foxboro Company). Use the info you obtain here at
your own risks. Read http://www.thecassandraproject.org/disclaimer.html
 
foxboro mailing list:             http://www.freelists.org/list/foxboro
to subscribe:         mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
to unsubscribe:      mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
 

Other related posts: