【问题标题】:Mounting an SMB drive via AppleScript通过 AppleScript 挂载 SMB 驱动器
【发布时间】:2013-11-01 12:52:04
【问题描述】:

我编写了一个 AppleScript 应用程序,它运行“mount -t smbfs”命令来安装我们员工使用的 Windows 共享驱动器。

到今天为止,该应用程序已成功使用数月。如果用户的密码中有 @ 符号,则应用程序将失败。路径被拒绝。

这是脚本:

-- Teaching Drive Access

--Get The Shortname and PC Password of current user 
--set PCusername to (short user name of (system info))
set PCusername to "benstaff"
--set PCPassword to text returned of (display dialog "What's your PC Password?" default answer "" with title "T Drive" with icon stop with hidden answer)

--Create Sharepoint on Desktop
set FolderTarget to (path to desktop folder as text) & "DoNotUseTeachingDrive"

try
    FolderTarget as alias
on error
    do shell script "mkdir /Users/" & PCusername & "/Desktop/DoNotUseTeachingDrive/"
end try

set mountcommand to "mount -t smbfs "
set mountuser to "//" & PCusername & ":" & PCPassword
set mountuser to "//" & PCusername & ":" & PCPassword
set mountvolume to "@ncs-srv-fs3.ncs.local/Teaching"
set machomepath to "/Users/" & PCusername & "/Desktop/DoNotUseTeachingDrive/"

set mountwindowshome to mountcommand & mountuser & mountvolume & " " & machomepath as string
do shell script mountwindowshome

mountwindowshome 的完整输出为:

mount -t smbfs //mystaff:PE91XA!!@@ncs-srv-fs3.ncs.local/Teaching /Users/mystaff/Desktop/DoNotUseTeachingDrive/

如果我在没有密码的情况下在终端中运行命令,系统会要求我输入密码并且共享已正确安装。

我们将不胜感激地收到任何帮助/指点。

【问题讨论】:

  • 您的密码似乎有问题。这个@@ 让你的 Mac 大吃一惊。

标签: macos bash applescript


【解决方案1】:

根据this site,您必须对特殊字符使用 url 转义。对于将是 %40 的 @ 字符,这会将挂载行变为:

mount -t smbfs //mystaff:PE91XA!!%40@ncs-srv-fs3.ncs.local/Teaching /Users/mystaff/Desktop/DoNotUseTeachingDrive/

【讨论】:

  • 看来我需要重新考虑我的脚本或如何安装共享。尝试“读取”每个密码并转换特殊字符是行不通的..
  • 迟到的评论,但您可以尝试 %-转义整个密码。这可能有效。
猜你喜欢
  • 2013-10-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-15
  • 2011-12-27
  • 1970-01-01
相关资源
最近更新 更多