Re: [foxboro] Command Line fdf/m1 to g file...

  • From: andreas.weiss@xxxxxxxxx
  • To: foxboro@xxxxxxxxxxxxx
  • Date: Fri, 27 May 2011 08:00:53 +0200

Tim,

I was not satisfied with the solution m1g provided by ...

It took some minutes to enhance m1g to m1g.ksh so that it is able to handle 
path names.

Tested on Solaris and without any warranties. Should work on Windows too.

Regards,
Andreas


m1g.ksh

#!/bin/ksh
#set -x

# Shell script to convert SL-GMS ".m1" files into equivalent ".g" files.
#
# Usage:
#      m1g /yourpathname/filename.m1     => converts filename.m1 to filename.g
# 

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/gms/bin

case $# in
    0) echo; echo "USAGE: $0 file.m1 ..."; echo; exit 1    ;;
esac

errorexit=""

for infile
do
    case $infile in
        *.m1) ;;
        *) echo "****ERROR: $infile does not have a .m1 suffix."
          errorexit=y; continue ;;
    esac

    if [ ! -f $infile ]
    then echo "****ERROR: $infile does not exist."; errorexit=y; continue
    fi

    echo ... $infile

    file=`basename $infile`
        PATH_INFILE=`dirname $1` 

        if [ ! -f "$file" ]
        then
          cp $infile .
          DODELETE=1
        else
          echo "sorry but the file $file already exists in "
          pwd
          DODELETE=0
        fi 

    file=`basename $infile .m1`

#    Cannot put tabs in here

    gml -l -tws -nws -w -y 1> /dev/null 2> /tmp/ttgml$$ << END_OF_SAVE
model get ${file}
${file} gsave
quit
END_OF_SAVE

    if    [ -s /tmp/ttgml$$ ]
    then    echo; echo "****ERROR message from gml"
        cat /tmp/ttgml$$; errorexit=y
    fi
done

\rm -f /tmp/ttgml$$

if [ "$DODELETE" -eq "1" ]
then
  \rm -f ${file}.m1
  mv ${file}.g $PATH_INFILE
else
  echo "nothing done"
fi

if    [ "$errorexit" ]
then    exit 1
else     exit 0
fi 
 
_______________________________________________________________________
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:             //www.freelists.org/list/foxboro
to subscribe:         mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
to unsubscribe:      mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
 

Other related posts: