Command line utility to create screenshot
It sounds like you're looking for the command screencapture, which, according to its man page, is to "capture images from the screen and save them to a file or the clipboard".

It's been a standard part of OS X since 10.2.