ArtEze
ArtEze

Reputation: 226

Get stdout from other program in Linux

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?

Upvotes: 1

Views: 6312

Answers (1)

Roman Hocke
Roman Hocke

Reputation: 4239

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>

Upvotes: 3

Related Questions