Thanks for the input everyone! In the end I stopped chasing the turning off of colors in Linux and fixed my problem the right way by just removing the control characters from the output in the script I was writing. Lee