To eject a CD on your Mac from the command line, type one of the following commands: drutil eject or drutil tray...
To burn a CD from the command line is very easy on a Mac. Just type the command below: hdiutil burn image.iso