Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: Compact sparse disk images via contextual menu' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Compact sparse disk images via contextual menu
Authored by: musickhead on May 29, '09 11:06:34AM

Nem points out that this doesn't work with encrypted images. Does anyone know how to provide the script with the necessary password? I don't think it can be done using arguments or variables or pipes. How do you catch the prompt for the password? The -stdinpass option doesn't seem to do anything. I would like to be able to do this so I can maintain the smallest possible backup of my files on a USB thumb drive.



[ Reply to This | # ]
10.4: Compact sparse disk images via contextual menu
Authored by: GlowingApple on Sep 11, '09 02:01:31PM
I believe echo -n "password" | hdiutil compact -stdinpass $@ should work.

---
--
~Jayson


[ Reply to This | # ]

10.4: Compact sparse disk images via contextual menu
Authored by: GlowingApple on Sep 11, '09 02:03:46PM

I should of course mention that this puts your password in the clear in the Automator script (anyone that has access to the script can read your password).

It would be much more secure to save the password in your Keychain instead.

---
--
~Jayson



[ Reply to This | # ]
10.4: Compact sparse disk images via contextual menu
Authored by: GlowingApple on Sep 11, '09 02:46:32PM
Sorry for the multiple posts, but I think I found a way to fix the encrypted image issues without having to store the password or post it in the clear in the script.

It seems that hdiutil prompts for a password from stdin by default. So the script will run, receive no input, and error out from an authentication failure. If you give hdiutil no option for input (by directing input from something like /dev/null), then it resorts to a graphical password prompt.

Use this code in the script and it should prompt for the password each time:
hdiutil compact $@ </dev/null

---
--
~Jayson


[ Reply to This | # ]