硬件温度报告

时间:2012-08-03 18:35:16

标签: macos applescript

我正试图找到一种方法来报告硬件温度,而不需要我下载的程序,我知道有很多可以做这个节目,但不要报告回网络上的远程位置

我发现了一个我可以修改的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

我再次玩弄这个,最后能够得到完整的错误 错误:无法生成44到41的字符#34; | | | | | \"版本\" = 2"进入类型字符串。

2 个答案:

答案 0 :(得分:0)

Scrip在“ioreg -c IOHWSensor”命令的输出中搜索单词“temperature” - 但如果从命令行执行该操作,而grep执行单词“temperature”则不会执行。至少我在我的系统上看不到它。 我的OsX 10.7你到底有什么?

答案 1 :(得分: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