POSIX path
POSIX path
- Subject: POSIX path
- From: "Sven-S. Porst" <email@hidden>
- Date: Thu, 10 Jan 2002 03:14:10 +0100
I recently discovered the 'POSIX path' property in Standard Additions. It
comes really handy when wanting to pass a file name to a command line
tool with the 'do shell script' command. Unfortunately it doesn't seem to
work for files whose names contain non-trivial (non-ASCII, I assume)
characters.
Say, I have a file called 'Bld' on my Desktop and myFile is an alias to
this folder, then
set myPath to POSIX path of myFile
puts "/Users/ssp/Desktop/Bld" into myPath. Invoking the command
do shell script "cat " & myPath
next gives an error message from 'cat' saying 'No such file or
directory'. I assume that the shell invoked by AppleScript can't handle
these characters and thus fails to find the file. In particular using the
tab completion offered by tcsh in the Terminal will give
[kalle:~/Desktop] ssp% cat Bla\314\210
which works, hence suggesting that the file name should be passed in this
way. Hence my next try was the command
do shell script "cat /Users/ssp/Desktop/Bla\\314\\210"
but this also fails with the error message
--> cat: /Users/ssp/Desktop/Bla314210: No such file or directory
.. and now I'm lost and have a couple of questions.
(a) Is there a way to convert the path to a representation that I can
actually pass to command line tools?
(b) Assuming I new the path as it is given by the Terminal, how could I
pass it to a command line tool in the 'do script command' parameter?
(Does the shell used by AppleScript define another escape character?)
The first question is of course more vital as otherwise I cannot process
files properly, the second one rather general interest. Any hints are
appreciated.
Sven
--
Sven-S. Porst . PGP: 0x0085ABA3 .
http://homepage.mac.com/ssp
Paranoia is the belief in a hidden order behind the visible.
-- Pi