Hello
I am really puzzled.
I never connected a mac to a network so my question may be dumb.
I am trying to help a user.
The script in progress is supposed to behave differently if it is running as a single machine or when it is running to a given network.
The user said that there are two volumes on the network, say inline1 and inline2 and if the mac is physically connected to the network, the script must execute
mount volume (insert the inline1 descriptor)
mount volume (insert the inline2 descriptor)
When it’s not physically linked to the network, the script open disk images to mount two image disks named inline1 and inline2.
I may code :
tell application "System Events"
set volumesAvailable to name of disks
end tell
set onNetwork to true
set inline1missing to volumesAvailable does not contain "inline1"
set inline2missing to volumesAvailable does not contain "inline2"
if inline1missing then
try
#mount volume (insert the inline1 descriptor)
on error
set onNetwork to false
end try
end if
if onNetwork and inline2missing then
try
mount volume (insert the inline1 descriptor)
on error
set onNetwork to false
end try
end if
if not onNetwork then
# here we aren't connected to the network
if volumesAvailable does not contain "inline1" then
tell application "System Events"
open disk item (path:to:the:image:inline1.sparsebundle)
end tell
end if # volumesAvailable 1
if volumesAvailable does not contain "inline2" then
tell application "System Events"
open disk item (path:to:the:image:inline2.sparsebundle)
end tell
end if # volumesAvailable 2
end if # not onNetwork
It may work but it I know that it requires several minutes to enter the correct part of code if the machine is not physically connected to the network.
Is there a more efficient automatic scheme ?
Of course, I may use a dialog box:
if machine alone then
click button [alone]
else
click button [networked]
end if
Yvan KOENIG (VALLAURIS, France) jeudi 26 février 2015 16:43:45