How to return drupal error message in php cli I am programmatically saving nodes with corresponding photos into a D7 content type.  It's working well sometimes, and failing on others, and I am sure it has something to do with a form field not having the right data.

Typically this would throw an error when manually uploading via the Drupal content type form, but I am using the PHP CLI.  How can I output that message to the CLI?

I tried 'print $messages' which is what is used for web pages, but, alas, that is not working.

Thanks
Since you are using the command line, have a look at PHP's input/output streams. These let you write data out to where your environment would be expecting to receive output. 

Alternatively, you might want a look at Drupal's built-in logging with watchdog(). You can see the messages it generates in Administration >> Reports >> Recent log messages.