2013-04-03 113 views
1

我想寫一個蘋果腳本來刪除我的sleepimage文件。終端命令做蘋果腳本刪除文件

sudo rm /private/var/vm/sleepimage 

顯然,我不能隨便鍵入到AppleScript的編輯器,所以我一直在使用這種

do shell script rm/private/var/vm/sleepimage with administrator privileges 

但隨着我得到這個錯誤

錯誤「變量rm未定義。」 「rm」號-2753

任何幫助將不勝感激,我知道它的簡單,但我不太好這個代碼的東西。

謝謝!

回答

1

我懷疑你只需要在你的微型Applescript中的一些引號。

嘗試:

do shell script "rm /private/var/vm/sleepimage" with administrator privileges 

,我會很驚訝,如果這是你最終使用在比賽的最後階段,因爲它會要求你(或某人),以輸入管理員用戶名每個&密碼該腳本被調用的時間。

0

更明智的解決方案是要做到:

sudo pmset hibernatefile /dev/null 

然後,一旦你刪除休眠文件一次,它是良好的刪除。

0

Try:

set myPath to "/private/var/vm/sleepimage" 
set usr to "username" 
set pswd to "password" 

do shell script "rm " & quoted form of myPath user name usr password pswd with administrator privileges