سؤال

Possible Duplicate:
How to invoke another terminal for output programmatically in C in Linux

I am programming a client-server application and I want to create a debug window.

On the server side I want to print the incoming and outgoing communication on a separate terminal. I am able to spawn a terminal through gnome-terminal but how to write on it and not on other terminals.

هل كانت مفيدة؟

المحلول

Combining idea of @ibid idea to what you want. Write to log file and than execute:

xterm -e tail "-f" log_file

This will span xterm , which executes "tai -f log file" command.

نصائح أخرى

Unless you for some reason really need to print to a terminal, I wouldn't bother, not just for a debug printout.

I would have the server print to a log file (remembering to flush it appropriately often) and then use tail -f in another terminal to follow it. This has the added benefit of giving me a record of what the server debug-printed that I can examine at leisure.

The "correct" answer to this question is that you can write to /dev/ttyNUM... if you know the right tty number.

But that's only technical correctness, you should do something else. What you're trying to do is wrong.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top