我有一个bash脚本,将通过ssh在Mac上运行。该脚本要求已挂载特定的网络驱动器。在苹果电脑上,我通过在Finder中打开该驱动器上的"JPLemme“文件夹来挂载该驱动器。这会挂载驱动器,直到Mac在晚上进入睡眠状态。
显然,Finder不能通过ssh使用,所以我想创建一个AppleScript来模拟我通过图形用户界面所做的事情。我试过了:
tell application "Finder"
activate
open "JPLemme"
end tell我收到以下错误:
execution error: Finder got an error: Can't get "JPLemme". (-1728)我想我遗漏了一些明显的东西,但是Google让我失望了。我也愿意考虑更好的解决方案,比如直接挂载驱动器;我避免了这种方法,因为我不想让Mac在以一种意想不到的方式挂载驱动器后,再次尝试挂载时卡住。(我不太喜欢Mac或AppleScript……)
发布于 2008-11-25 19:39:12
您的网络卷应该有某种类型的域附加到它。所以,"JPLemme.domain.com“。我使用以下代码块进入一个受密码保护的网络卷:
tell application "Finder"
try
set theServer to mount volume "smb://path/to/volume" as username "YourUserName" with password "YourPassword"
--Please note here that this is a plain string without any built-in security. Use at your own risk.
on error
set VolumeCount to (get count of disks)
repeat with x from 1 to VolumeCount
set thisVolume to disk x
if name of thisVolume is "JPLemme" then
set theServer to thisVolume
exit repeat
end if
end repeat
end try
end tell您可以根据需要清理它,但这是它的核心。祝好运
发布于 2008-11-26 14:52:07
在它的核心,所有真正需要的是:
Tell Application "Finder"
Mount Volume "smb://username:password@server/sub/directory"
End Tell但是使用什么将在很大程度上取决于网络环境和返回的错误。
https://stackoverflow.com/questions/317857
复制相似问题