Scripting : How get Command Result ?

From a script, is it possible to get the reply of a openocd command to make some test on its result ?