What is the best way to generate a bit-perfect / accurate / secure rip of an audio CD (or DVD) to create a perfect bin/cue file of the disc?

I do not want to encode it (mp3 or flac or...) at this point. Just want to archive the disc perfectly and encode it later.

A command line mode would be ideal as I plan to use robotics to do the job.

Thanks for your help!
iamnemo