Macos AppleScript加载卷装载,启动应用程序,并在mac退出挂起状态时重新启动。
我的Mac连接到网络上的SMB共享,然后立即加载应用程序时遇到一些问题 在大多数情况下,当mac打开时,只要像往常一样将卷设置为登录时挂载,并在登录时运行应用程序(XBMC),一切都会正常工作 偶尔,在经过大量的故障排除后,由于没有任何原因,我无法确定卷的自动装载有时会失败,因为它认为网络位置不可用。因此,Mac无法创建卷装载,除非我重新启动Mac,然后它才能再次工作 现在我想要一个AppleScript,它将尝试创建三(3)次卷装载,然后加载XBMC。如果尝试3次后无法装入卷,请强制Mac重新启动。这将导致脚本在重新启动后重新运行 我如何在AppleScript中实现这一点 第二个问题: 我的Mac设置为在1小时不活动后挂起。唯一的问题是,如果Mac电脑已经暂停了一段时间,那么XBMC在醒来后的某段时间内无法加载远程存储的内容 那么,是否有可能在Mac从暂停状态恢复时运行脚本,从而使Mac重新启动 感谢所有读过我全部文章的人,我意识到这有点像在咆哮Macos AppleScript加载卷装载,启动应用程序,并在mac退出挂起状态时重新启动。,macos,applescript,restart,xbmc,Macos,Applescript,Restart,Xbmc,我的Mac连接到网络上的SMB共享,然后立即加载应用程序时遇到一些问题 在大多数情况下,当mac打开时,只要像往常一样将卷设置为登录时挂载,并在登录时运行应用程序(XBMC),一切都会正常工作 偶尔,在经过大量的故障排除后,由于没有任何原因,我无法确定卷的自动装载有时会失败,因为它认为网络位置不可用。因此,Mac无法创建卷装载,除非我重新启动Mac,然后它才能再次工作 现在我想要一个AppleScript,它将尝试创建三(3)次卷装载,然后加载XBMC。如果尝试3次后无法装入卷,请强制Mac重新
问候。第一个问题试试这个。至于你的“暂停”问题,我现在还不知道答案。不过我会调查launchd。您可能可以编写一个launchd plist文件,该文件在mac恢复时运行,该launchd plist将使用命令行工具osascript运行applescript
set remoteDiskName to "Disk Name"
set remoteIPAddress to "192.168.1.xxx"
set user_name to "userName"
set pass_word to "password"
repeat 3 times
set success to mountSMB(remoteDiskName, remoteIPAddress, user_name, pass_word)
if success then exit repeat
delay 1
end repeat
if success then
-- load XBMC
else
tell application "Finder" to restart
end if
on mountSMB(remoteDiskName, remoteIPAddress, user_name, pass_word)
if remoteDiskName is in (do shell script "/bin/ls /Volumes") then
return true
else
set theAddress to quoted form of ("smb://" & user_name & ":" & pass_word & "@" & remoteIPAddress & "/" & remoteDiskName)
set mountpoint to quoted form of ("/Volumes/" & remoteDiskName)
try
do shell script "/bin/mkdir " & mountpoint & "; /sbin/mount_smbfs " & theAddress & space & mountpoint
return true
on error
try
do shell script "/bin/rm -r " & mountpoint
end try
return false
end try
end if
end mountSMB
谢谢你。还有一件事,我如何让这个脚本在Mac启动时自动运行?那么,它什么时候登录?像平常一样将其设置为登录项?正如最初的评论员所说的那样查看launchd。如果你不想弄乱plists,那就去appstore买Lingon吧,它可以帮你处理大部分的脏活。