burning question

I’ve been playing around with this script today, but I’ve run into a snag.

display dialog "Please Insert the CD-Rom You Would Like to Copy And Enter the Exact Name of that CD-Rom" default answer "" buttons {"Cancel", "OK"} default button "OK" with icon 1
--delay 30 -- allow some time for the disc to mount
set diskName to (text returned of result)

do shell script "hdiutil unmount "/Volumes/" & diskName & """
get word 1 of result
set devName to result
tell application "Terminal"
	activate
	do script "hdiutil convert /dev/" & devName & " -format UDTO -o "$HOME/Desktop/" & diskName & """
	delay 360 --allow some time for the copying process, adjust accordingly
	
	display dialog "Please Eject the CD-Rom Named ”" & diskName & "”" buttons {"Cancel", "OK"} default button "OK" with icon 1
	display dialog "Burn It or Don't" buttons {"Cancel", "OK"} default button "OK" with icon 2
	--tell application "Terminal"
	--do script "hdiutil burn " & diskName & ".dmg &" - noverifyburn - noeject --dangit I cant seem to get this line to work
	--it needs to add .dmg to the file name and do the " - noverifyburn - noeject" part of the command, any help??? 
	--end tell
end tell

The snag is I can’t seem to properly escape & diskName & ".dmg &


do script "hdiutil burn " & diskName & ".dmg &" - noverifyburn - noeject

it needs to add the .dmg extension to the file name. Everything I try seems to fail and Applescript sees “- noverifyburn - noeject” as variables. Any Help?


Yippee & Yahhoo, I fixed it…

display dialog "Please Insert the CD-Rom You Would Like to Copy And Enter the Exact Name of That CD-Rom" default answer "" buttons {"Cancel", "OK"} default button "OK" with icon 1
--delay 30 -- allow some time for the disc to mount
set diskName to (text returned of result)
do shell script "hdiutil unmount "/Volumes/" & diskName & """
get word 1 of result
set devName to result
tell application "Terminal"
	activate
	do script "hdiutil convert /dev/" & devName & " -format UDTO -o "$HOME/Desktop/" & diskName & """
end tell
do shell script "sleep 300" --allow some time for the copying process, adjust accordingly
tell application "Finder" to activate
display dialog "Please Eject the CD-Rom Named ”" & diskName & "”" buttons {"Cancel", "OK"} default button 1 with icon 1
display dialog "Burn It, Durn It" buttons {"Cancel", "OK"} default button "OK"
tell application "Terminal"
	do script "cd $HOME/Desktop;hdiutil burn "" & discName & ".dmg" -noverifyburn -noeject"
end tell

I guess I need to do a little tweaking now. Do yourself a favor and add the search window to the SE 2.0 toolbar, it’s nice to have.

If your disk name has spaces in it, Terminal will probably choke. I would probably try to build the path before passing it to Terminal and then run it through a POSIX path routine.

set posixPath to quoted form of POSIX path of myPath

Actually, the hdiutil command gets the disc name from the /dev directory with a name like “disk5s1s2” which it uses as the disk name (unix junk) so it really doesn’t use the actual cd-rom’s name itself. I’m trying to pass the actual cd-rom’s name to the shell so that it names the .dmg file the same as the original cd-rom that is being copied via the variable 'diskName. I’ll figure it out someday, maybe. I just need to be able to add the extension (.dmg) to the file name before it tries to burn it. The burn part is the commented out section of the script.

I might try dropping the " - noverifyburn - noeject" from the script to see what happens.

I haven’t done any Terminal scripting but I have done some shell scripts via the ‘do shell script’ command. I wonder if it would help to take the Terminal out of the picture. I also notice that you have a ‘tell application “Terminal”’ within another Terminal tell block. It might not hurt anything but I doubt that it helps either.

Geez, I feel like a real dummy at times…

do script "hdiutil burn " & diskName & ".dmg &" - noverifyburn - noeject

All I had to do was remove the last ampersand after the .dmg extension and set the escapes correct (Edited @ 3:15 cst).

do script "hdiutil burn "" & diskName & ".dmg" - noverifyburn - noeject"

Funny how something that simple can stump me for hours. Then when I look at it the next day, I go DUH! :shock:

Rob, the first tell block for the terminal app opens a terminal session that shows the copying progress. Normally, I use the “do shell script” command, but I thought it would be better to be able to see the copying progress in this case.

The second tell block is still being tested, I may remove it later. I just wanted to get it working first. Thanks for your input, it brought up some other ideas ;¬D

I’ll most likely use the shell’s ‘sleep’ command rather than Applescript’s ‘delay’ as the ‘delay’ command is processor intensive. Delay vs Sleep @ OSXHints

Now I wonder if I can put it in the background via the terminal. Hmm-mm. (There is a way to do that by using an ampersand at the end of a command)

Anyhow the script has some portability issues, for instance…
My Machine copies the “Mac OS X Install Disc 1” in about 3.5 minutes. Other Machines will be faster or slower due to their config’s. So, users will have to adjust the delays/sleeps accordingly.