LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to Log all Terminal (/dev/pts/0) activities to a file? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-log-all-terminal-dev-pts-0-activities-to-a-file-4175621476/)

demJanus 01-12-2018 06:18 AM

How to Log all Terminal (/dev/pts/0) activities to a file?
 
Hi all,

I have a process that is spawned from a server process and that redirects its stdout to a console, for example /dev/pts/0 where I can watch its output.
But due to this I cannot use tee or so to copy and log the output to a file as I am not the starter/owner of the process.

Is there a way to either
a) grab all data that is incoming to /dev/pts/0 and write it to a file?
or
b) create a new device /dev/myconsole which in turn writes data sent to it somehow to a file and additionally to /dev/pts/0 so that I can use this device as output device in the server application?

Thanks for your suggestions :)

Best regards,
Janus

pan64 01-13-2018 04:08 AM

I would rather make a wrapper script which will be started by that server process and this script will run your process and grab the data you need.

demJanus 01-13-2018 11:31 AM

Thanks for your suggestion, but I cannot make any modifications there. I can only set the target where stdout is redirected to...

scasey 01-13-2018 11:34 AM

Can you direct the output to a file and then use tail -f to watch the file?

pan64 01-13-2018 11:46 AM

what kind of os is it? you may try to use the terminal itself to save the content (probably)?

demJanus 01-13-2018 12:52 PM

OS is Debian. Actually I did not yet try what happens if I give a file path instead of a /dev/tty/. I think internally freopen() is being used for redirection. Could it really be that simple? If so shame on me :) I will try on Monday.


All times are GMT -5. The time now is 06:14 AM.