Script for collecting data from Debug Window

Is there a way to collect the data from the debug window automatically and save it inot a text file to be used by another process?