2012-08-03 56 views
0

我想找到一种方法来报告硬件温度回到我没有一个程序,我不得不下载,我知道很多做的显示,但不报告回到远程位置上的网络。硬件温度报告

我发现了一个applescript,我可能会修改它以使其正常工作,但我目前正在步骤1中停止运行脚本。

下面是我找到的脚本。我一直在标线得到一个错误,幸运的13行 错误只是说不能得到项目17

set the_result to (do shell script "ioreg -c IOHWSensor | grep -vE '\\{|\\}|\\+\\-o'")'s paragraphs 

set all_display to "" 
repeat with i from 0 to 16 

    set jump to 3 
    set the_location to item (3 + (jump * i)) of the_result 
    set the_location to characters 41 thru ((count of characters of the_location) - 1) of the_location as string 
    set the_type to item (4 + (jump * i)) of the_result 
    set the_text to item (2 + (jump * i)) of the_result as string 
    **set the_text to characters 44 thru (count of characters of the_text) of the_text as string --(length of item 2 of the_result)** 
    set the_type to characters 37 thru ((count of characters of the_type) - 1) of the_type as string 
    if the_type = "temperature" then 
     set all_display to all_display & " 
" & the_location & ": " & ((the_text/65536) * (9/5)) + 32 & " F" as string 
    end if 
end repeat 

display dialog all_display 

我与这一次终于能够得到完整的错误 错误玩弄:无法将“| | | | | \”version \“= 2”中的字符44到41转换为字符串类型。

回答

0

脚本在“ioreg -c IOHWSensor”命令的输出中搜索单词“temperature” - 但是如果从命令行执行该命令并且grep单词“temperature”则不会有任何命令。至少我没有看到我的系统上。 我的是OsX 10.7你有什么?

+0

10.6.8 我的理解是,虽然所有的英特尔Mac的将在很大程度上类似。 显然,如果他们不是那会是一个问题。 但是,此脚本在温度之前出错。 – 2012-08-06 12:32:36

+0

我的观点是,它永远不会找到温度关键字。无论如何,你可以简单地删除| grep -vE'\\ {| \\} | \\ + \\ - o'从脚本运行并再次运行。它试图摆脱+ o \ |符号。 – artapet 2012-08-08 05:12:38

0

我相信这个信息由IOHWSensor通过ioreg报告。这一个班轮工作对我来说:

echo $((`ioreg -c IOHWSensor | grep "current-value" | grep -oE [0-9]+`/65536)) 

除以65536可能是硬件相关。有些MAC将值存储为10的倍数,2的其他幂等。除以正确的数字后,我相信结果总是以ºC为单位。

延伸阅读: http://www.cminow.org/ioreg_perl.html