mount image from terminal with finder dialog

Discussion in 'Mac Programming' started by d1squiet, Dec 9, 2018.

  1. d1squiet macrumors newbie

    Joined:
    Dec 9, 2018
    #1
    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.
     
  2. chabig macrumors 603

    Joined:
    Sep 6, 2002
    #2
    If you just leave the password out of the terminal command, won't it present to the user?
     
  3. d1squiet thread starter macrumors newbie

    Joined:
    Dec 9, 2018
    #3
    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.
     
  4. chabig macrumors 603

    Joined:
    Sep 6, 2002
    #4
    Instead of using hdiutil, just use "open". That works the way you want.

    open <path to disk image>
     
  5. d1squiet thread starter macrumors newbie

    Joined:
    Dec 9, 2018
    #5

    ha! so simple. will the script pause for the dmg to mount? I wonder... will see.
     
  6. chabig macrumors 603

    Joined:
    Sep 6, 2002
    #6
    I not an expert. I just learn by trial and error. Let me know.
     
  7. d1squiet thread starter macrumors newbie

    Joined:
    Dec 9, 2018
    #7
    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!
     

Share This Page

7 December 9, 2018