Get stdout from other program in Linux

Viewed 18

I want in Linux, get the stdout of a NodeJS program that is opened, from other NodeJS program or bash.

I have the PID, or name of program and the data, put to function in real time.

Maybe touching files in /proc?

This is possible?

1 Answers

You can use strace -e write -p <pid> to see what output is the program writing to stdout (or other FDs) in real time. It does not show what has been written earlier and it needs a little parsing to extract clean stdout contents.

By default, it truncates shown writes to only 32 characters. To show more, use -s switch:

strace -e write -s 9999 -p <pid>
Related