• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get HFS Path of POSIX Path?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get HFS Path of POSIX Path?


  • Subject: Re: Get HFS Path of POSIX Path?
  • From: Courtney Schwartz <email@hidden>
  • Date: Fri, 24 Sep 2004 11:31:05 -0400

I had a similar situation... My solution was just to make sure that the drive was mounted before I ran the POSIXy script. You could easily do this with a "do shell script " line if you're willing to edit the sudo file and if you don't routinely unplug that mounting drive.

Here's what I did:
0) Make sure any non-normal drives (disk images, flash cards, etc.) have been ejected. Basically, you're looking to find where your drive normally mounts on restart, without any other temporary drives, so restarting or unmounting then re-mounting the drive after ejecting all others can help this.
1) In Terminal ,
sudo visudo <return>
<enter your password, assuming you have admin status>
2) Use the arrow keys to move your cursor to the line at the end of the "# User privelege specification" block. Press the "a" key to append. Paste (Apple-V) the text "yourusername ALL=NOPASSWD: /usr/bin/hdid". (This specifies that you don't have to enter an admin password to mount a drive using the hdid command.) Press the escape key to get back into command mode, then ":wq" to give visudo a command to write the file and quit.
3) mount <return>
This listing should tell you where on the POSIX file system your drive normally mounts. For example, the "/dev/disk1s4 on /Volumes/FireWire (local, nodev, nosuid)" line it returned told me that the device was mounted under /dev/disk1s4. Note this POSIX location. Exit Terminal.
4) Add this line to your AppleScript before you use the mounted folder:
do shell script "hdid /dev/disk1s4 >> /dev/null" --Or wherever else "mount" told you your drive mounts.


Note that hdid will fail if the drive is *already* mounted, so you have to redirect its output to the aether to keep things running without complaint.

Maybe it's not what you need, but it might be. :)

Courtney Schwartz


On Sep 24, 2004, at 11:00 AM, Johnny AppleScript wrote:

Thanks Paul,

I knew there was a way of manipulating the POSIX class, but my SA dictionary. Only shows this:

Class POSIX file: A file object specified with a POSIX (slash)-style pathname.
Properties:
    POSIX path  'file'  [r/o]  -- the POSIX (slash)-style path of any file or alias object


I simply could not coerce that underlined object in my brain to get the 'POSIX file' method you reminded me of below.

Is there something wrong with my dictionary, or am I just not reading the first line (Class POSIX file:) properly? Note that it is in black text (i.e., it does not appear in green as my app keywords do), which I took to just be a header line, not a command.

 Thanks -- (a confused)JA


On 04/09/24 8:21 AM, "Paul Berkowitz" <email@hidden> wrote:

> On 9/24/04 7:06 AM, "Johnny AppleScript" <email@hidden> wrote:
>
>>
>> I tried to search my own archives and samples before asking; isn't there a
>> method, other than a text replacement subroutine, to get the HFS path to an
>> object from its POSIX equivalent?
>>
>> have: "/Users/Library/Folder/Object
>> need: ":volumename:Users:Library:Folder:object"
>> where: Users directory is on a volume other than startup volume
>
> POSIX file "/Users/Library/Folder/Object"
>
>   will compile to
>
> file "Disk:Users:Library:Folder:Object"
>
> (It's in the Standard Additions.) You'll find that in order to use it that
> that 'file' thing doesn't do much and needs instead:
>
> POSIX file "/Users/Library/Folder/Object" as alias
> --> alias "Disk:Users:Library:Folder:Object"
>
> or
>
> POSIX file "/Users/Library/Folder/Object" as Unicode text
> --> "Disk:Users:Library:Folder:Object"
>
>
> (The shorthand you've been using of omitting the startup disk in Mac (colon)
> paths will probably stop working someday.)
>
>>
>> I'm finding some problems with file paths when the UNIX path leads (via
>> symlink or otherwise) to another volume when using text replacement for
>> paths (which works most of the time, otherwise).
>
> This method will work even when the POSIX path starts "/Volumes/" etc.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden
_______________________

Courtney Schwartz

Documentation Specialist
Global Technology Associates
3505 Lake Lynda Dr. Suite 109
Orlando, FL 32817 USA
(407) 380-0220 x1427

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Get HFS Path of POSIX Path? (From: Johnny AppleScript <email@hidden>)

  • Prev by Date: Re: Get HFS Path of POSIX Path?
  • Next by Date: Re: Get HFS Path of POSIX Path?
  • Previous by thread: Re: Get HFS Path of POSIX Path?
  • Next by thread: Re: Get HFS Path of POSIX Path?
  • Index(es):
    • Date
    • Thread