Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

d1squiet

macrumors newbie
Original poster
Dec 9, 2018
4
0
I'm trying to write a bash script that will mount an encrypted disk image. I've been using hdiutil and have figured out how to pass a password to the command, but it would be much simpler for me if hdiutil just opened a finder dialog box (like what happens when I double-click on a dmg file). That is to say, I'd love the bash script to pause and let the finder deal with the passoword/encryption. Is this possible?

I thought maybe i had to use diskutil instead of hdiutil, but I couldn't figure out how to pass a dmg file to the diskutil command.
 
If you just leave the password out of the terminal command, won't it present to the user?
 
If you just leave the password out of the terminal command, won't it present to the user?
Only in the terminal as far as I know.
I'm looking to eventually run it in the background, or within an apple-script or such. I'm sure I will figure out a method I like, but seems like the functionality of letting the OS handle it would be nice. Also for non-terminal-friendly users it would look normal.
 
Instead of using hdiutil, just use "open". That works the way you want.

open <path to disk image>
 
It didn't work at first – the script keeps going. A little research revealed that "open -W" will force the calling application (the bash script in this case) to pause until open is done. So far it works perfectly.

thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.