Re: Is this legit? [POSIX]
Re: Is this legit? [POSIX]
- Subject: Re: Is this legit? [POSIX]
- From: "Nigel Garvey" <email@hidden>
- Date: Fri, 25 Jul 2008 13:56:37 +0100
Thanks again to everyone who's contributed thoughts to my query since
last time. The message I'm getting is that the POSIX file coercion effect
I discovered is highly questionable and that its use is to be avoided if
possible.
My Jaguar machine doesn't like the "stat" shell script, but gives usable
results with the "perl" and "ls" ones. All three work with Tiger. 'read
file "path:to:symbolic:link"' returns the _contents_ of the current time
zone file. I can't see if this contains the time zone name I want.
"Mark J. Reed" wrote on Thu, 24 Jul 2008 12:28:33 -0400:
>In descending preference for this particular need, I would like to ask
>the system about time zone preferences by
For me, the thinking would be:
>(1) using a function designed to ask the system for time zone
>preferences!
However, none has come to light in the discussion so far. So:
(2) using a method known to work with Jaguar, Tiger, and the early
versions of Leopard (and so presumably with Panther too) and which stands
the best chance of continuing to work in the future. There are never any
right answers to this! My own feeling, based on my minimal exposure to
Unix and system preference files, is that the symbolic link set-up is
more likely to last than the paragraph structure of preference files. Of
the shell-script based symbolic link followers that have been offered,
there doesn't appear to be anything to choose between the two that work
across all the systems, except that the perl one is very slightly faster.
That's probably the one for which I'll settle.
-- "perl". (Faster than "ls"):
set tz to (do shell script "perl -le 'print readlink(\"/etc/
localtime\")' | cut -d / -f 5-")
-- Or, faster:
set tzPath to (do shell script "perl -le 'print readlink(\"/etc/
localtime\")'")
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "zoneinfo/"
set tz to text item 2 of tzPath
set AppleScript's text item delimiters to astid
tz
(3) exploiting the "symbolic link as POSIX file" quirk that occasioned
this thread. Probably to be avoided, even though it currently works
across all the required systems and wipes the floor with the other
methods for speed. (Given that the time zone will only be checked once
per run of the script, speed isn't a primary consideration here.)
NG
_______________________________________________
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