From f8553136ddeedbc977c7d7a8353d5a868e8f09ec Mon Sep 17 00:00:00 2001 From: "Bastian M. Wojek" Date: Fri, 26 Sep 2008 07:24:52 +0000 Subject: [PATCH] bug fixes in the mlog2db script --- src/external/scripts/mlog2db | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/external/scripts/mlog2db b/src/external/scripts/mlog2db index 9eda110a..ea1e42fb 100755 --- a/src/external/scripts/mlog2db +++ b/src/external/scripts/mlog2db @@ -1,12 +1,12 @@ #!/bin/bash -if [ ! -e /usr/bin/awk ]; then +if [ ! -x /usr/bin/awk ]; then echo Please make sure you have installed awk! exit 1 fi -if [ $# -lt 2 ] ; then - +if [ "$#" -lt 2 ] ; then + cat < nextinput else if($1 == "RUN") { @@ -244,7 +244,7 @@ else musrfit $COUNT$EXTENSION.msr $MUSRFITPARAM # the fit - if [ "$COUNT" != "${RUNARRAY[$LASTRUN]}" ]; then # create the next musrfit input file if not the last specified run was fitted already + if [ "$q" -ne "$LASTRUN" ]; then # create the next musrfit input file if not the last specified run was fitted already awk -v count=$COUNT -v nextcount=$NEXTCOUNT -v nextinput=$NEXTINPUT '{ if(NR==1) print nextcount > nextinput else if($1 == "RUN") { @@ -257,9 +257,9 @@ else fi fi - if [ ! -e $COUNT$EXTENSION.mlog ]; then + if [ ! -r $COUNT$EXTENSION.mlog ]; then echo - echo "The specified musrfit output file "$COUNT$EXTENSION".mlog does not exist!" + echo "The specified musrfit output file $COUNT$EXTENSION.mlog does not exist!" echo exit 1 fi @@ -305,7 +305,7 @@ else # put together all data to db-format and write it to the file awk -v optPARone=$OPT_PAR_ONE -v optPARtwo=$OPT_PAR_TWO -v optPARthree=$OPT_PAR_THREE -v optPARfour=$OPT_PAR_FOUR \ - -v optPARfour=$OPT_PAR_FIVE -v runList=$RUNLIST_USED -v numIndVar=$NUM_OF_IND_VAR '{ + -v optPARfive=$OPT_PAR_FIVE -v runList=$RUNLIST_USED -v numIndVar=$NUM_OF_IND_VAR '{ outfile="out.db" if(optPARone ~ /^-o/) outfile = substr(optPARone,3) @@ -384,7 +384,7 @@ else if("'"$TEMPERATURE"'" != "") { # Write the db-header - if("'"$COUNT"'" == "'"${RUNARRAY[0]}"'" && optPARone != "noheader" && optPARtwo != "noheader" && optPARthree != "noheader" && optPARfour != "noheader" && optPARfive != "noheader"){ + if("'"$q"'" == 0 && optPARone != "noheader" && optPARtwo != "noheader" && optPARthree != "noheader" && optPARfour != "noheader" && optPARfive != "noheader"){ print "TITLE" >> outfile print ">>>Put your title here<<<\n" >> outfile @@ -450,12 +450,12 @@ else print dataArray[i+3] ",,, " "'"$TITLE"'" >> outfile - if("'"$COUNT"'" == "'"${RUNARRAY[$LASTRUN]}"'") print "\n" >> outfile + if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile } # If we do not have the information from the summary file or "nosummary" is set else { - if("'"$COUNT"'" == "'"${RUNARRAY[0]}"'" && optPARone != "noheader" && optPARtwo != "noheader" && optPARthree != "noheader" && optPARfour != "noheader" && optPARfive != "noheader"){ + if("'"$q"'" == 0 && optPARone != "noheader" && optPARtwo != "noheader" && optPARthree != "noheader" && optPARfour != "noheader" && optPARfive != "noheader"){ print "TITLE" >> outfile print ">>>Put your title here<<<\n" >> outfile @@ -501,7 +501,7 @@ else print dataArray[i+3] ",,, " title >> outfile - if("'"$COUNT"'" == "'"${RUNARRAY[$LASTRUN]}"'") print "\n" >> outfile + if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile } } }' $COUNT$EXTENSION.mlog