I want to move a file to an employee folder on a server. I can get the name of the folder on the server because it corresponds to the user name of the computer. so if I do whoami in a shell script I get the user name and the name of their folder. How can I add the response to the whoami to the server path?
ditto ~/Documents/Microsoft\ User\ Data/Office\ 2004\ Identities/Main\ Identity/Database /Volumes/EMPLOYEE_BACKUP/whoami info here/Database
I almost have it working. I have added an if statement to see if the server is mounted. I get and error if the server is mounted that says The variable result is not defined. If the server is not mounted everthing works great.
set iVolume to "EMPLOYEE_BACKUP"
if (list disks) does not contain iVolume then tell application "System Events" to get name of current user
set iUser to result
display dialog "Enter Network Password" default answer "" with hidden answer
set iPass to the text returned of the result
set iServer to "afp://myserver/EMPLOYEE_BACKUP"
mount volume iServer as user name iUser with password iPass
do shell script "/Library/Scripts/my_Scripts/backup_database.sh"
if (list disks) contains iVolume then
do shell script "/Library/Scripts/my_Scripts/backup_database.sh"
end if
set iVolume to "EMPLOYEE_BACKUP"
if (list disks) does not contain iVolume then
tell application "System Events" to set iUser to name of current user
display dialog "Enter Network Password" default answer "" with hidden answer
set iPass to the text returned of the result
set iServer to "afp://myserver/EMPLOYEE_BACKUP"
mount volume iServer as user name iUser with password iPass
end if
do shell script "/Library/Scripts/my_Scripts/backup_database.sh"