I want to duplicate a file from a mounted AFP volume called ‘SPARE500gb’ to a folder on the startup disk without referencing to it by its name as I want anybody to be able to run the script when saved out as an application. The script just mounts an AFP volume then runs a duplicate command. Here is the code I have so far;
set serverIP to "XX.XX.XX.XX" --enter the ip of the server here
set ShareName to "SPARE500gb" -- enter the share name here ***Make sure it is in "CAPS"
set username to "user" --you know what this is
set pass to "password" --And this one ass well
--only edit the above code
tell application "Finder"
try
set server_Off to "Server Not On!!"
set server_On to "Server Mounted!!"
set server_AlreadyOn to "Server Already On"
set ping_result to (do shell script "ping -c 1 -q " & serverIP)
if "100% packet loss" is in ping_result then
display dialog server_Off buttons "OK" default button 1 with icon 2
error number -128 --user cancelled
end if
mount volume "afp://" & username & ":" & pass & "@" & serverIP & "/" & ShareName
on error number -55
display dialog server_AlreadyOn buttons "OK" default button 1 with icon 2
error number -128 --user cancelled
end try
end tell
tell application "Finder"
duplicate file "SPARE500gb:GISVPN.pcf" to "????:private:etc:opt:cisco-vpnclient:Profiles"
end tell
I have blanked the IP address for obvious reasons, the bit with the question marks above is where I would want to reference the startup disk. The script works if I put my drive name in ‘MANMEW1008’
PS. On the PC’s you can normally reference the startup disk with ‘%systemroot%’ is this possible on the MACS??
tell application "Finder"
duplicate file "SPARE500gb:GISVPN.pcf" to (((path to startup disk) as text) & "private:etc:opt:cisco-vpnclient:Profiles") as alias
end tell
‘Finder got an error: Can’t make startup disk into type constant.’
I just copied the code you sent me replacing the code that I had after the last ‘end tell’ command, is that right? So the code now looks;
set serverIP to "10.68.45.52" --enter the ip of the server here
set ShareName to "SPARE500gb" -- enter the share name here ***Make sure it is in "CAPS"
set username to "user" --you know what this is
set pass to "password" --And this one as well
--only edit the above code
tell application "Finder"
try
set server_Off to "Server Not On!!"
set server_On to "Server Mounted!!"
set server_AlreadyOn to "Server Already On"
set ping_result to (do shell script "ping -c 1 -q " & serverIP)
if "100% packet loss" is in ping_result then
display dialog server_Off buttons "OK" default button 1 with icon 2
error number -128 --user cancelled
end if
mount volume "afp://" & username & ":" & pass & "@" & serverIP & "/" & ShareName
on error number -55
display dialog server_AlreadyOn buttons "OK" default button 1 with icon 2
error number -128 --user cancelled
end try
end tell
tell application "Finder"
duplicate file "SPARE500gb:GISVPN.pcf" to (((path to startup disk) as text) & "private:etc:opt:cisco-vpnclient:Profiles") as alias
end tell
It highlights up the (path to startup disk) as where the error occurs, did you want me to change that? if i have to supply the volume name that won’t work will it because the script will be running from different machines who each have their own volume name.
“path to” is part of the Standard Additions, but the Finder won’t understand it. You could try this:
get (((path to startup disk) as text) & "private:etc:opt:cisco-vpnclient:Profiles")
tell application "Finder" to duplicate file "SPARE500gb:GISVPN.pcf" to result
This should also work:
tell application "Finder"
duplicate file "SPARE500gb:GISVPN.pcf" to ((name of first disk whose startup is true) & ":private:etc:opt:cisco-vpnclient:Profiles")
end tell
To add a little more security to the script I added a little extra command to dismount the volume once the copy completed.
An extra challenge would be that if the script could launch or install some software aswell. Basically its the Cisco VPN client for Mac OS Tiger 10.4.2, this needs installing and then some settings applied so the user can use VPN to our network. The file that gets copied is the settings file that the VPN client uses to read in the settings, that way the user doesnt actually need to be told any of the settings for security reasons. The installer is a .PKG file, is there anyway to script the installation into this script aswell. So the sequence of events would be;
Connect to Fileserver and mount volume SPARE500gb
Install CiscoVPN Client software
Copy GISVPN.pcf file into the profiles directory after the installation has completed so all the configuration is made (might need a wait command to let 2. finish)
Create a DOCK item or Alias of the CiscoVPNClient.app to the Desktop
Unmount volume ‘SPARE500gb’
That way anybody that has a MAC laptop anywhere on our network that wants VPN can just run the script as an application that I give them before they leave and just double click on the shortcut when they go offsite.