OK, I still don't know what this itk program is though and have not found any information about it online. The only software I could find called itk is a medical imaging library, not sure if that's the one you are talking about. Can you provide any more detail on where this itkadmin program comes from? I just thought if we knew exactly what software we were dealing with, there might be other options available to catch/deal with errors.
Anyway, I have found this thread on stack overflow that might help you:
http://stackoverflow.com/questions/3515208/can-colorized-output-be-captured-via-shell-redirect
Apparently, the 'script' command will start a new shell and run a specified command/script and will write the output from the shell session to a typescript file. If colourised output is enabled in the shell, the escape codes for the colour will be written to the typescript file.
So you could call your script via the script command and then parse each line in the typescript file and search for the colour code for red (01;31m will probably suffice). For any lines that contain the red colour code (or any other colours you need to detect), you will then need to determine the filename and then do whatever you need to do to that file - Append the filename to a list of failed files, run another script etc...
So as a simple, contrived example:
Code:
script -c 'grep Keyword --color ~/' OUTPUT
The above would start a new shell and run a grep command which will search for any files in my home directory that contained the word 'Keyword'. Output from the command is written to a typescript file called OUTPUT. And because colourised output was enabled in grep, any instances of 'Keyword' will be highlighted in a different colour in the shell and the escape sequence used to generate that colour will be written to the typescript file. As a sanity check, by opening the typescript file in a text editor, you should be able to see the escape sequences used to generate the colours.
So that would be one option. Not sure if that is any good for you?!
You might need to read the man/info pages for the script command to see if you can get it to do what you want!
Bearing the above information in mind, perhaps this will do the trick:
Code:
script -c 'itkadmin config -nwid ora2gchild -set nd.baseMomSchemaFile -edit' OUTPUT
Once that has completed, you need to run a command/script to open the OUTPUT file, find any lines containing the escape-codes for the colours you are looking out for. Once you've found a line containing the escape-code you'll need to determine the name of the file that the command failed for and then do whatever you need to do in the event of a failure!