2012-08-03 34 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