Re: how to use mount volume with timeout argument in AppleScript.
Re: how to use mount volume with timeout argument in AppleScript.
- Subject: Re: how to use mount volume with timeout argument in AppleScript.
- From: "Amit Jain" <email@hidden>
- Date: Fri, 4 Aug 2006 10:08:15 +0530
---------- Forwarded message ----------
From: Amit Jain <email@hidden>
Date: Aug 3, 2006 9:53 PM
Subject: Re: how to use mount volume with timeout argument in AppleScript.
To: Ryan Britton <email@hidden>
Thanks for your reply Ryan and Gnarlodious,
But I have to mount through applescript only and I used the following
script as suggested by Gnarlodious:
with timeout of 10 seconds
mount volume "smb://theUser:thePassword@theAddress/theVolume"
beep 2
end timeout
but if theAddress has some invalid address applescript hangs for a
long time in search of that address irrespective of the timeout time
i.e. here 10 seconds.But my requirement is to force it to only search
for some specific time limit after that it shud give an error message.
Waiting for the answers....
Regards....
On 8/3/06, Ryan Britton <email@hidden> wrote:
If you're just interested in mounting an SMB share, you can do this in
Carbon with better results.
//These are defined elsewhere
NSString *server;
NSString *user;
NSString *password;
NSString *path;
FSVolumeRefNum mountReference;
//Mounting
NSURL *url = [NSURL URLWithString:[[NSString
stringWithFormat:@"smb://%@/%@", server, path]
stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
if (!url)
{
return NO;
}
OSStatus result = FSMountServerVolumeSync((CFURLRef) url,
NULL, (CFStringRef) user, (CFStringRef) password, &mountReference, 0);
//Get the mount path
FSRef volPathRef;
OSErr err = FSGetVolumeInfo(mountReference, 0, NULL, kFSVolInfoNone, NULL,
NULL, &volPathRef);
if (err != noErr)
{
return nil;
}
char *pathChars = (char *) malloc((PATH_MAX + 1) * sizeof(char));
OSStatus result = FSRefMakePath(&volPathRef, pathChars, PATH_MAX);
pathChars[PATH_MAX] = 0;
if (result != noErr)
{
free(pathChars);
return nil;
}
NSString *mountPath = [NSString stringWithUTF8String:(char *) pathChars];
free(pathChars);
//Unmounting
pid_t dissenter;
OSStatus result = FSEjectVolumeSync(mountReference, 0,
&dissenter);
On Aug 3, 2006, at 12:33 AM, Amit Jain wrote:
Hi All,
Is there any way to reduce the searching time of mac while trying to
mount any IPAddress
through apple script. I had tried but I am unable to use an argument
for timeout in the following command:
tell application "Finder"
mount volume
"smb://any-user:password@ipaddress/sharedVolume"
end tell
where shud I put the timeout argument or if anyone knows a better way
to do the same.
I am using this code in my application but it hangs for longtime when
I enter a wrong IPAddress which I have to reduce.I think I have tried
my best to explain my problem.
Please help ASAP.
Thanks in advance..
Regards..
Amit
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden