2013-11-01 69 views
2

我編寫了一個AppleScript應用程序,它運行「mount -t smbfs」命令來掛載我們員工使用的Windows共享驅動器。通過AppleScript掛載SMB驅動器

該應用程序已成功使用了幾個月,直到今天。如果用戶的密碼中有@符號,則應用程序失敗。路徑被拒絕。

這裏的腳本:

-- 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:[email protected]@ncs-srv-fs3.ncs.local/Teaching /Users/mystaff/Desktop/DoNotUseTeachingDrive/ 

如果我運行在終端的命令沒有密碼問我密碼和共享正確安裝。

任何幫助/指針將受到感謝。

+0

看起來問題在於您的密碼。這個'@@'吹掉了你Mac的頭腦。 –

回答

2

根據this site,你必須在特殊字符上使用url轉義。對於@字符,這將是%40,這會將安裝線變爲此:

mount -t smbfs //mystaff:PE91XA!!%[email protected]/Teaching /Users/mystaff/Desktop/DoNotUseTeachingDrive/ 
+1

Ypu沒有錯誤的'@'。 –

+0

謝謝。我修好了它。 –

+0

看起來我需要重新考慮我的腳本或股票的掛載方式。嘗試「讀取」每個密碼並轉換特殊字符是不會起作用的。 – notverypc