Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax error

Status
Not open for further replies.

Marcel1958

Technical User
Oct 11, 2001
38
NL
I have some problems with the let TOTAAL=$TOTAAL+$freemb command in mine script:
The messages on the console are:

MEM T0156
63,0
0
/usr/bin/leesnmon[66]: TOTAAL=0+63,0: 0403-057 Syntax error


Hereby a part of the script.

BESTAND="./prd01_030417_0915.nmon.csv"



while read -r type teller realfree virtfree freemb virtfreemb rotzooi
do
if [ "$type" = "MEM" ]
then
print "$type $teller"
let AANTAL=$AANTAL+1
print $freemb
print $TOTAAL
let TOTAAL=$TOTAAL+$freemb
fi

done < $BESTAND
 
Een eenvoudige correctie, Gebruik de steunen:

(( AANTAL = $AANTAL + 1 ))

Ik hoop dat helpt !

Dickie Bird (:)-)))
 
Thanks for your reaction. The problem is not the statement you corrected but the statement:

let TOTAAL=$TOTAAL+$freemb

 
I think that your problem is that freemb=&quot;63,0&quot; is not a number. You can cut off everything after the comma using ...
[tt]
freemb=$(echo $freemb|cut -d',' -f1)
[/tt]
 
looks like you BESTAND is a csv (CommaSeparated) file, but your're 'read'-ing lines with default field seprated which space (value of the IFS env. var):

while read -r type teller realfree virtfree freemb virtfreemb rotzooi

If you want to read fields which are comma separated change the above to:

while IFS=',' read -r type teller realfree virtfree freemb virtfreemb rotzooi

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks Ygor and Vlad.

Your both right. The IFS in the file is ; What i have done is:

freemb=$(echo $freemb|tr -d &quot;,&quot;)

The comma is now removed. Now i have to add the comma to the result. So 643 must become 64,3

Any idea?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top