add function to capture a process output into a string