The following script...
open location "smb://fileserver02.domain1.com.au/department"
works as expected, it connects to the drive and prompts the user to enter username and password. However, when I try to build the domain and username into the command and then connect, the open location command does not work, no error it just simply does nothing.
set userName to do shell script "whoami"
set p to "\"smb:DOMAIN2\\" & userName & "@fileserver02.domain1.com.au/department\"" as string
open location p
I've confirmed that the string is being built correctly into the p variable and it works if I type the command out like so...
open location "smb:DOMAIN2\\[email protected]/department"
It just does not work when its contained in a variable...
Any help is greatly appreciated, thanks.
CodePudding user response:
Remove the literal double quotes at the beginning and the end of the string. As the current short username cannot contain special characters you don't need to escape the entire string.
On the other hand to get two backslashes you have to escape both.
set userName to do shell script "whoami"
set p to "smb:DOMAIN2\\\\" & userName & "@fileserver02.domain1.com.au/department"
open location p
CodePudding user response:
Don't put escaped quotes at both ends of your variable.
set userName to do shell script "whoami"
set p to ("smb:DOMAIN2//" & userName & "@fileserver02.domain1.com.au/department") as string
open location p