Re: Vexing POSIX file issue
Re: Vexing POSIX file issue
- Subject: Re: Vexing POSIX file issue
- From: Loren Ryter <email@hidden>
- Date: Thu, 13 Mar 2008 14:03:45 -0400
- Thread-topic: Vexing POSIX file issue
Thanks for the responses.
First of all to Mark, yes, the remote volume "David" (which is the user home
directory on the remote machine) IS mounted as a volume on the local
machine.
What I am trying to accomplish ultimately is to get a Finder alias to a file
on the remote volume. To do this, I ask a remote application to give me a
UNIX path (which begins with "/Users/David/", ie, it is relative to the
remote machine.)
I then change that path to a path relative to the local machine (which
begins with "/Volumes/Users/David/"). Then I get the local POSIX file, and
then I get a local alias.
So Chris, here is the code.
set remotehome to "David"
set remotepw to "<ENTER YOUR PASSWORD>"
set remotemachineip to "seventeen.local"
set remotemachine to ("eppc://" & remotehome & ":" & remotepw & "@" &
remotemachineip & ":3031/") as string
using terms from application "DEVONthink Pro"
tell application "DEVONthink Pro" of machine remotemachine
set remotedbpath to path of (current database)
log "remotedbpath"
end tell
end using terms from
set remotedbpath to replace(remotedbpath, "/Users/" & remotehome,
"/Volumes/" & remotehome) of me
log "remotedbpath"
log remotedbpath
try
set remotedbhfs to (POSIX file remotedbpath)
log " remotedbhfs"
log (remotedbhfs as string)
on error myerr
log "error"
log myerr
end try
try
set remotedbfile to remotedbhfs as alias
log "remotedbfile (alias)"
log (remotedbfile as string)
on error myerr
log "error"
log myerr
end try
on replace(source, search, replacement)
if class of source is list then
if source is {} then return {}
return ({replace(beginning of source, search, replacement)} &
replace(rest of source, search, replacement))
else
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to the search
set the textItemList to every text item of the source
set AppleScript's text item delimiters to the replacement
set the output to the textItemList as string
set AppleScript's text item delimiters to oldDelim
return output
end if
end replace
On 3/13/08 12:51 PM, "Christopher Nebel" <email@hidden> wrote:
> Guessing a bit from the event log, is the "/Volumes/David/..." path
> actually a path on a remote machine? And your machine doesn't have a
> "David" disk? The HFS-POSIX conversion relies on knowing what volumes
> are available, because of the root-vs-non-root distinction, so it
> won't necessarily work right for a path that came from a remote
> machine. Also, there are ways to mess up the conversion that would
> lead to effects like this; your code would help more than the event log.
>
>
> --Chris Nebel
> AppleScript Engineering
>
> On Mar 13, 2008, at 8:39 AM, Loren Ryter wrote:
>
>> I'm getting a bug report from a user running 10.5.2 that I can't
>> reproduce
>> on my end involving setting POSIX File on a file on his mounted
>> network home
>> folder.
>>
>> Getting the POSIX File of:
>>
>> /Volumes/David/Documents/Devonthink Dbase/David's DEVONthink
>> Database.dtBase
>>
>> Returns:
>>
>> Macintosh HD:Volumes:David:Documents:Devonthink Dbase:David's
>> DEVONthink
>> Database.dtBase
>>
>> Instead of the expected:
>>
>> David:Documents:Devonthink Dbase:David's DEVONthink Database.dtBase
>>
>> Therefore, coercing that HFS path in an alias fails with an error.
>>
>> My work around involves string substitution. But why should POSIX
>> file get
>> that result in the first place? And why is it happening on his
>> machine and
>> not on mine? And why wouldn't coercing the erroneous return into an
>> alias
>> work?
>>
>> Thanks!
>>
>>
>> Here's the event log:
>>
>> tell application "DEVONthink Pro" of machine "eppc://seventeen.local:
>> 3031"
>> get path of current database
>> "/Users/David/Documents/Devonthink Dbase/David's DEVONthink
>> Database.dtBase"
>> (*remotedbpath*)
>> (*/Users/David/Documents/Devonthink Dbase/David's DEVONthink
>> Database.dtBase*)
>> (*remotedbpath*)
>> (*/Volumes/David/Documents/Devonthink Dbase/David's DEVONthink
>> Database.dtBase*)
>> (*remotedbhfs*)
>> (*Macintosh HD:Volumes:David:Documents:Devonthink Dbase:David's
>> DEVONthink Database.dtBase*)
>> (*error*)
>> (*CanĀ¹t make file "Macintosh HD:Volumes:David:Documents:Devonthink
>> Dbase:David's DEVONthink Database.dtBase" into type alias.*)
>> end tell
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> AppleScript-Users mailing list (applescript-
>> email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> Archives: http://lists.apple.com/archives/applescript-users
>>
>> This email sent to email@hidden
>
_______________________________________________
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