Re: Mount volume
Re: Mount volume
- Subject: Re: Mount volume
- From: Sander Tekelenburg <email@hidden>
- Date: Wed, 18 Feb 2009 16:47:59 +0100
At 08:48 -0500 UTC, on 2009-02-18, Script2 wrote:
> I recently changed from 10.3.9 to 10.4.11 on one of the MAC. I had script on
> 10.3.9 that would mount 5 volumes without any problem. On 10.4.11 when I run
> this script it mounts sometimes 2 or 3 volumes never all 5. I tried adding
> "delay" in between but this does not work.
>
> Tell application "Finder"
> If not (exists disk "Data") then
> Try
> Mount volume "afp://ruby:email@hidden/Data"
> End try
> End if
[0] Is that really the code you use? The capitalization suggests otherwise...
(Or perhaps your mail client is just trying too hard to be 'clever'.)
[1] Do not place things in tell blocks unless they *need* to. (See also the
recentish thread "Tell Blocks Considered Harmful"). The "mount volume"
command is part of Standard Additions, so there is no good reason to wrap it
in a tell block that targets Finder (unless you're into 'interesting' results
;)). So do something like this instead:
tell app "Finder"
if not (exists disk "Data") then
tell me
try
mount volume "afp://ruby:email@hidden/Data"
end try
end tell
end if
end tell
or like this:
tell app "Finder"
set diskExists to (exists disk "Data")
end tell
if diskExists then
try
mount volume "afp://ruby:email@hidden/Data"
end try
end
(Probably better even to use "System Events" instead of "Finder".)
[2] Your try block tells the script to ignore errors, so when it fails you
get zero feedback about what problem it ran into. Instead, at least while
debugging, grab the actual error number and message. They'll likely tell, or
at least hint at, what the problem is:
try
mount volume "afp://ruby:email@hidden/Data"
on error ErrMessage number ErrNumber
display dialog "Err number " & ErrNumber & return & ErrMessage
end try
[3] Are you sure the volumes are not mounted? The Mac OS X Finder is crap
(even in Leopard still). One of its ever-lasting bug is that it doesn't
reflect changes until it considers the phase of the moon just right, where
"just right" is decided upon by a randum number generator.
The more reliable way to verify whether something is or isn't mounted is by
using Terminal.app:
$ ls /Volumes
[4] I tend to use this slightly different syntax:
mount volume "afp://10.0.2.11/Data" as user name "ruby" with password "1234"
Just maybe the other syntax triggers a bug. Doesn't hurt to try.
--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden