I am using using hdiutil to mount a sparseimage file and it works fine when I type the command into terminal but when I try to run it as a shell script it gives a error.
Here is the code:
echo -n 'password' | hdiutil attach -stdinpass file.sparseimage
This is the error:
hdiutil: attach failed - Authentication error
I am sure that the password is correct. Can anyone tell me what is wrong?
The EXAMPLES section of the hdiutil
documentation recommends using printf
for this rather than echo -n
.
Creating an encrypted single-partition image without user interaction:
printf pp|hdiutil create -encryption -stdinpass -size 9m sp.dmg
If you are testing against 10.9 betas, do make sure to test with both the very latest version and with 10.8. I only bring this up because I have encountered some STDIN-related bugs with early version of 10.9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With