2

I am currently testing some programs for my project, I have this program currently running as a daemon I would just like to capture the standard output of this program and maybe the stderr ...

I know strace would have been best as a debugging tool but I guess it does not streamline to my want ..

i see answers on stackoverflow like the subprocess.popen(['ps'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) ... but this start the process .. I just want to hook to a running process and grap output...

any answer or ideas would be appreciated .. if in python, bash or c

1
  • 1
    To be able to communicate with already running process you have to set a watchers for them. The most common tools for this are Tmux and Screen. Commented Jun 9, 2020 at 23:55

2 Answers 2

1

To be able to communicate with already running processes you have to set a watchers/listeners on those processes before starting them.

You can see the most common tools for this use, which are Tmux and Screen.

Then I think that you'll be able to do whatever you want with the output of those processes depending on the API provided by the tool you'll use.

This is the first idea I had when I saw the question.

Sign up to request clarification or add additional context in comments.

Comments

0

you can use redirection in bash so like << >> to send the outputs of programs into log files. Lets say you run

echo time

you could do

echo time << log.txt

There is also also error output and what. If you don't want to look at manpages, try this.

https://www.gnu.org/software/bash/manual/html_node/Redirections.html

1 Comment

I really got some help from the link but does the file descriptor /dev/stdout saves output unlike /dev/null ...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.