MACSCRPT Archives

June 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Philip Aker <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sat, 10 Jun 2006 19:26:07 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (55 lines)
On 2006-06-10, at 16:36:26, Brian Johnson wrote:

> Yes, the "'file-path as alias' in a try block" approach is Finder- 
> free, and really elegant, but it doesn't handle folders in the path  
> that are LNKs (not sure about aliases). The Finder test (and  
> apache) does OK with LNK'd folders. (At least, according to my  
> notes in the source!). This particular "FileExists" function has  
> had both incarnations, but currently uses the Finder tell block  
> because I need to handle chunks of web-site that are on other  
> volumes). Time to come up with another strategy!

> As you say, perhaps some bizarre interaction ...

Hi Brian,

I'm unable to test on 10.3 any longer (old machine died) but I'd  
expect some thing like:

set fexists to "if [ -e /Library/WebServer/Documents/ ]; then
echo \"Kilroy was here\"
else
echo \"Kilroy was not here\"
fi"

do shell script fexists

to work on both systems. For paths in AppleScript, I actually prefer  
to use System Events even though it usually requires more work to get  
the same result. For POSIX, paths I mostly use Tcl:

do shell script "echo 'puts [file exists /Library/WebServer/ 
Documents]' | tclsh"
--> 1

As you can see, the terminology is not quite as obscure as sh. The  
above is compatible back to 10.0

HTH,

>> You don't need the Finder to verify file existence. Can't really
>> explain the crash though unless it's some bizarre interaction with a
>> symlink from httpd or maybe even a simple permissions error.
>>
>> try
>>      set cgi to ("Macintosh HD:Library:Webserver:Documents:cgi-
>> bin:nope.html") as alias
>>      return true
>> on error errs
>>      return false
>> end try


Philip Aker
[log in to unmask]

ATOM RSS1 RSS2