property usrn : "" --< do NOT pick in your username here!
property pswd : "" --< do NOT pick in your password here!
(* Just save this script as application. Within first script-start you will be asked
for username & password and it will be stored as property in the script-app for the future.
But please customize the vars "serv" and "volList" in the next two paragraphs,
that's all to do in Script Editor. *)
set serv to "192.0.0.0"
set volList to {"Voume1", "Volume2", "Volume3"}
set firstMount to true
-- :::::::::::::::::::::::::::::::::::::::: hohabadu.de ::::::::::::::::::::::::::::::::::::::::
(* © by H =:o) L G I (alias Holger Hansen)
Ich würde mich freuen, wenn bei Verwendung des Codes oder Teilen davon
diese Zeilen erhalten bleiben, zumindest aber die Zeile m. d. Hinweis auf die Website *)
-- username & password configuration
if usrn is "" and pswd is "" then
set usrn to text returned of (display dialog "Username for Server \"" & serv & "\":" default answer "username")
set pswd to text returned of (display dialog "Password for Server \"" & serv & "\":" default answer "password" with hidden answer)
end if
-- mounting volumes, if necessary and the Server is available
-- check, if the server is available
if my checkServer(serv) then
repeat with vol in volList
-- check, if volume isn't already mounted
if vol is not in (list disks) then
-- check, if that's the first attempt to mount a volume of the server
if firstMount then
try
mount volume "afp://" & usrn & ":" & pswd & "@" & serv & "/" & vol
on error
mount volume "afp://" & serv & "/" & vol
end try
else
mount volume "afp://" & serv & "/" & vol
end if
end if
set firstMount to false
end repeat
else
activate
display dialog "Server \"" & serv & "\" isn't available at this moment!" with icon stop giving up after 20
end if
on checkServer(ServerIP)
try
set t to do shell script "ping -c 1 " & ServerIP
if t contains "0% packet loss" then
return true
else
return false
end if
on error
return false
end try
end checkServer