View Full Version : Creating .dmg images from the shell
iceman22
Apr 3, 2005, 10:29 AM
I have written a PHP script I run using cron, which takes arguments as files or directories to back up to an FTP server.
The script takes the args and executes the shell command hdiutil to make a compressed, encrypted image.
It works great, except that I currently get this error:
hdiutil: WARNING: -passphrase has been deprecated in favor of -stdinpass
When using this shell command within the script:
hdiutil create -srcfolder $source -encryption -passphrase $password -fs HFS+ -volname $vol_name $img_name
I haven't been able to enter a password using stdin either from the shell, is it even possible to use -stdinpass in a CGI?
Bear
Apr 3, 2005, 10:47 AM
...
I haven't been able to enter a password using stdin either from the shell, is it even possible to use -stdinpass in a CGI?From a Terminal window, you need a null character (^@) at the end of your passphrase and on the next line a control-D (^d). Without the null, it doesn't work.
As for using it within a cgi, yes it can be done, you would need to write the null terminated password to a file (no control-D should be needed as all that does is indicate end of file) and run hdiutil redirecting stdin to be from the file.
iceman22
Apr 3, 2005, 11:04 AM
Would you mind providing an example of how it could be done in a CGI?
I have tried entering a passphrase followed by a '^@' and was unsuccessful in the terminal. I just tried again and the passphrases didn't match, even when I was copying exactly what I had typed into the shell window that was still open, excluding the NULL char of course.
iceman22
Apr 3, 2005, 10:40 PM
I successfully created an image from the shell, using (^@), rather than literally typing caret-@, which did not work.
I can't do ctrl-@ in a text file or in the script, only caret-@, I have tried using "password^@","password\0","password" and a few others.
In the script, this is what I have tried using:
`cat /password.txt | hdiutil create -srcfolder $source -encryption -stdinpass -fs HFS+ -volname $vol_name $img_name`
`echo "$password^@" | hdiutil create -srcfolder $source -encryption -stdinpass -fs HFS+ -volname $vol_name $img_name`
iceman22
Apr 3, 2005, 11:47 PM
I got it work, there is no need for a NULL terminating character or using an external file. The fact that echo was adding a \n by default is what was killing me.
This works fine:
`echo -n $password | hdiutil create -srcfolder $source -encryption -stdinpass -fs HFS+ -volname $vol_name $img_name`;
anurag1005
Aug 12, 2010, 12:26 AM
Hi,
I am using same command in shell script to create a dmg file but after creation I am not able to open the dmg with same password. If I am creating the dmg from command line it works fine.
echo -n abcd1234|hdiutil create -srcfolder my_folder -encryption -stdinpass -debug my_folder.dmg
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.