Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Encrypted disk image mounting

I'm trying to find a way to make an AppleScript that will mount an encrypted disk image and enter the password for it automatically. I can make it open all right, but I can't figure out how to make it enter the password (the 'with password' command doesn't seem to work, I'm assuming it only works on remote volumes?).

Any help would be appreciated.

1.25 gHz Mini, Mac OS X (10.4.6)

Posted on Oct 3, 2006 11:24 AM

Reply
Question marked as Best reply

Posted on Oct 3, 2006 12:34 PM

Something like this should work:
<pre>
set myResult to display dialog "Enter password:" default answer "" with hidden answer
set thePW to text returned of myResult

set cmd to "echo -n \"" & thePW & "\" | hdiutil attach /path/to/encrypted/disk/image.dmg -stdinpass"
do shell script cmd
</pre>
There are some security concerns with passing a command string to "do shell script" that contains your password. If other users log on to your machine they could see your password if they happened to be watching the process list at just the right time.

Steve
2 replies
Question marked as Best reply

Oct 3, 2006 12:34 PM in response to Khadrelt

Something like this should work:
<pre>
set myResult to display dialog "Enter password:" default answer "" with hidden answer
set thePW to text returned of myResult

set cmd to "echo -n \"" & thePW & "\" | hdiutil attach /path/to/encrypted/disk/image.dmg -stdinpass"
do shell script cmd
</pre>
There are some security concerns with passing a command string to "do shell script" that contains your password. If other users log on to your machine they could see your password if they happened to be watching the process list at just the right time.

Steve

Encrypted disk image mounting

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.