Home > Enterprise >  Get stdout from other program in Linux
Get stdout from other program in Linux

Time:09-09

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?

CodePudding user response:

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