availability: January 2017
I wanted to automate the creation of an MS-DOS floppy under MacOSX. The usual way is very similar to Linux. In this script I avoided using sudo to mount the filesystem and took advantage of the hdiutils to run everything under normal user credentials.
<% codify({:lang => :shell }) do %>
dd if=/dev/zero bs=512 count=2880 of=msdos-floppy.img
device=hdid -nomount msdos-floppy.img
newfs_msdos $device
hdiutil detach $device -force
device=hdid msdos-floppy.img|cut -d ' ' -f 1
path=mount |grep -w '$device' | cut -d ' ' -f 3- | cut -d '(' -f 1
cp file $path/
hdiutil detach $device -forceend
<% end %>