Hi guys, I am trying to help a friend debug a script. I have only started learning tcl and haven't gotten to math functions yet. The question would be best stated in the code that's being used.
First is the code that retrieves the info for us...
Code: Select all
if {[catch {exec cat /proc/cpuinfo | grep "cpu MHz"} cpuspeed]} {set cpuspeed "Unknown"}
Then according to that code it should parse the Mhz command or reply with "Unknown".
Then to parse "cpu MHz : 1596.000" (without the quotes)
Code: Select all
set cpuspeed "[expr double(round([string map {"cpu MHz : " ""} $cpuspeed]))]"
What is going wrong? Is the mhz not coming back correctly? This is the error code.
Code: Select all
Tcl error [msg_uptime]: syntax error in expression "double(round(1596.000 1596.000))": missing close parenthesis at end of function call
so I assume it has to do with the double command. It worked when used with a 700mhz CPU. The only other code related to cpu further down is this...
Code: Select all
if {$cpuspeed >= 1000} {
set cpuspeed "[expr $cpuspeed/1000]GHz"
} else {
set cpuspeed "[expr round($cpuspeed)]MHz"
I know this is something easy but I am way too tired and sick to figured it out myself or skip ahead in my tcl books and try to fill in the knowledge. Any help would make me much grateful. Thank you.
- Tony R.