I was trying to set the destination volume in time machine via script using the statement below:
do shell script “tmutil setdestination "afp://” & uname & “:” & pword & “@” & mvol & “"” with administrator privileges
uname is username
pword is password
and mvol is the destination
This works unless the user has a @ sign in their password. I was wondering if there was an efficient way to handle this. I’m new to applescript as in I only started working with it this month. Shortly before posting this, I came up with opening a terminal window and passing the password through the window but it’s not a very clean way to do it.
A clip of my script is below. I left out the parts that define my variables since the main point is the @ sign in the password.
do shell script "echo tmutil setdestination -p '\"'afp://ESUDOM'\\'" & leftString(email, "@") & "@" & mvol & "'\"' > ~/tmutilscript" with administrator privileges do shell script "echo echo PROCESS COMPLETE! This window can be closed. >> ~/tmutilscript" with administrator privileges do shell script "chmod 777 ~/tmutilscript" with administrator privileges tell application "Terminal" set currentTab to do script "sudo ~/tmutilscript" delay 5 do script lpword in currentTab delay 5 do script pword in currentTab end tell
The first part creates a shell script. The second part executes the script and passes the local admin password and the domain password that contains the @ sign. As you can see, it’s kind of messy. It leave the terminal running in the background and there is that 5 second delay so that slower machines will run the script correctly. Without the delay, some machines were sending the password before the terminal was ready.
So I’m hoping there is a more efficient way to set up the time machine destination. Thank you.