我正在创建一个applescript,它在Mac Os X 中创建/Users 文件夹的备份图像。我想做以下两件事之一:
- 在 shell 脚本运行时显示理发杆进度条,并带有退出选项。
- 在脚本运行时显示一个对话框,并带有退出选项。
我曾尝试使用 /dev/null 执行 shell 脚本,但这会忽略所有输出。我想保存输出并将其显示在用户的对话框中。
这是我的代码:
set computername to (do shell script "networksetup -getcomputername")
set fin to ""
set theIcon to note
tell application "Finder"
try
set folderalias to "/Users"
set foldersize to physical size of folder (alias ":Users") --(info for folderalias)
set foldersize to (round ((foldersize / 1.0E+9) * 100)) / 100
on error
tell application "System Events"
set foldersize to (round (((get physical size of folder ":Users" as text) / 1.0E+9) * 100)) / 100
end tell
end try
end tell
display dialog "User profile backup utility" & return & return & ¬
"The computer name is: " & computername & return & return & ¬
"The '/Users/' directory size is: " & "~" & foldersize & " GB" & return & return & ¬
"Would you like to backup the '/User' directory now?" & return ¬
buttons {"Cancel", "Backup Now"} default button "Backup Now"
set comd to "hdiutil create ~/Desktop/" & computername & ".dmg -srcfolder /test/"
set fin to do shell script (comd) with administrator privileges
display dialog fin