Home Forums OS X Server and Client Discussion Questions and Answers Creating an encrypted disk image in a shell script

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #380421
    fluffels
    Participant

    After jumping through quite a few hoops and filling a sparseimage, the backup script I’m creating needs to convert said sparseimage to a read only disk image, which is encrypted.

    Currently, I have this:

    [code]hdiutil convert -quiet $bkpath/$tempname -format UDRO -o $bkpath/$endname -encryption -passphrase $password[/code]

    Obviously this isn’t ideal as -passphrase has been deprecated in favour of -stdinpass.

    Thing is, my brain isn’t working well enough to actually make -sdinpass work. How would I go about passing the variable $password off as input to this line?

    #380447
    mosen
    Participant

    Hiya,

    stdin can be passed through a pipe. so the following might do what you would like:
    [code]
    echo -n $password | hdiutil convert -quiet $bkpath/$tempname -format UDRO -o $bkpath/$endname -encryption -stdinpass
    [/code]
    the -n is important for echo because otherwise you will end up with a password having a newline character.

    Mo.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Comments are closed