Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got two separate programs running that each generate a log file (one is the output of device attached to a serial port, the other is the debug messages sent from a program commanding the aforementioned device).

What I'd like to be able to do is to correlate the debug messages printed by the commanding software with the responses received from the serial device. However, because the two programs are separate, it's not possible for me to have a look at a debug message in one file and figure out what data was sent back from the serial port at the same time.

What I'd like to find is something that can take the file streams of the two programs and combine them into one file.

I imagine a solution might work like this:

I'd set up the two programs to save their log files to two "virtual files", which would be created and monitored by this solution. The solution would continually monitor these virtual files and save their output to another file as an when data is written to the files.

share|improve this question
add comment

1 Answer

If these are commands that can be started from the command line, then you could do this with any good Unix shell, starting them as background activities using the & operator, piping both stdout and stderr through tee to write them into a log and display them.

Here's how you might do it using my Hamilton C shell. (You can do similar stuff with Cygwin bash.)

(command1 &; command2 &) |& tee logfile.txt

Two background processes under Hamilton C shell

The extra lines with the digits 1 to 4 in the screenshot are the background thread ids written to stderr by the & operator.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.